コード例 #1
0
ファイル: ServerCommand.cs プロジェクト: edisplay/Razor
        protected override Task <int> ExecuteCoreAsync()
        {
            // Make sure there's only one server with the same identity at a time.
            using (var mutex = new Mutex(initiallyOwned: true, name: MutexName.GetServerMutexName(Pipe.Value()), createdNew: out var holdsMutex))
            {
                if (!holdsMutex)
                {
                    // Another server is running, just exit.
                    Error.Write("Another server already running...");
                    return(Task.FromResult(1));
                }

                try
                {
                    var host         = ConnectionHost.Create(Pipe.Value());
                    var compilerHost = CompilerHost.Create();
                    var dispatcher   = RequestDispatcher.Create(host, compilerHost, Cancelled);
                    dispatcher.Run();
                }
                finally
                {
                    mutex.ReleaseMutex();
                }
            }

            return(Task.FromResult(0));
        }
コード例 #2
0
        protected virtual void ExecuteServerCore(ConnectionHost host, CompilerHost compilerHost, CancellationToken cancellationToken, EventBus eventBus, TimeSpan?keepAlive)
        {
            var dispatcher = RequestDispatcher.Create(host, compilerHost, cancellationToken, eventBus, keepAlive);

            dispatcher.Run();
        }