private static void CreateLockFile() { if (LockFile != null) { LockFile.Close(); } var tmppath = Path.GetTempPath(); string lockpath; do { lockpath = Path.Combine(tmppath, Path.GetRandomFileName()); } while (File.Exists(lockpath)); LockFile = File.Open(lockpath, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.Read); }
/// <summary> /// 断开连接,关闭策略服务器 /// </summary> static void StopStrategyServer() { // 断开连接 BlueHandle.Close(); YellowHandle.Close(); NormalExiting = true; //lock (BlueServerLock) //{ // if (BlueServer != null) // { // try // { // BlueServer.Kill(); // BlueServer.WaitForExit(); // } // catch (Exception ex) // { // Logger.MainLogger.LogError(ex.ToString()); // Debug.LogError(ex); // } // } //} //lock (YellowServerLock) //{ // if (YellowServer != null) // { // try // { // YellowServer.Kill(); // YellowServer.WaitForExit(); // } // catch (Exception ex) // { // Logger.MainLogger.LogError(ex.ToString()); // Debug.LogError(ex); // } // } //} LockFile.Close(); File.Delete(LockFile.Name); }