Esempio n. 1
0
    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);
    }
Esempio n. 2
0
    /// <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);
    }