コード例 #1
0
        public bool Stop()
        {
            if (cancellationSource != null)
            {
                cancellationSource.Cancel();//this will throw
                try
                {
                    hubInfoLoop.Wait();
                    mainLoop.Wait();
                }
                catch (Exception ex)
                {
                    Logger.LogError(ex.Message);
                }
            }
            cancellationSource = null;

            hubInfoLoop = null;
            mainLoop    = null;

            if (httpService != null)
            {
                httpService.Stop();
            }
            httpService = null;

            return(true);
        }
コード例 #2
0
        public bool Start()
        {
            if (mainLoop != null)
            {
                throw new Exception("Service is already running!");
            }

            golemApi   = new PeerApi(Options.GolemHubUrl);
            ServerPort = Options.GolemServerPort;

            taskQueue = new ConcurrentQueue <CompilationTask>();

            cancellationSource = new System.Threading.CancellationTokenSource();

            //run the hub info loop (peer discovery)
            hubInfoLoop = GolemHubQueryTask(cancellationSource.Token);
            //hubInfoLoop.Start();

            //run main task loop
            mainLoop = TaskDispatcher(cancellationSource.Token);

            //run the http server
            httpService = new GolemHttpService();
            httpService.Start();

            return(mainLoop != null);
        }