예제 #1
0
        public string Execute(string request)
        {
            var task1 = new Task <string>(() =>
            {
                var webSocketClient = WebSocketClientManager.GetInstance().GetClientById(_websocketClientId);
                if (webSocketClient != null)
                {
                    OperationManager.GetInstance().AddOperation(Token, this);
                    webSocketClient.Send(request);
                    Log.InfoFormat("Request: {0}", request);

                    while (!blockToken.IsCancellationRequested)
                    {
                        Thread.Sleep(300);
                    }

                    OperationManager.GetInstance().RemoveOperation(Token);
                    Log.InfoFormat("Response: {0}", _response);
                    return(_response);
                }
                else
                {
                    Log.WarnFormat("Cannot file websocket client={0}", _websocketClientId);
                    return("");
                }
            }, blockToken.Token);

            task1.Start();
            task1.Wait();

            Log.InfoFormat("task1.Result: {0}", task1.Result);
            return(task1.Result);
        }
예제 #2
0
 public static void Initialize()
 {
     Repository.RepositoryManager.AddAssemby(typeof(Repository.Mybatis.MsSql.NinjectBinder).Assembly);
     OperationManager.GetInstance();
     WebSocketClientManager.GetInstance();
 }