private static void StartRESTApi(Object poObject) { RESTServerParams loParams = poObject as RESTServerParams; mbRESTApiStarted = true; using (WebApp.Start <Startup>(url: loParams.ToString())) { StopServerEvent.Wait(); } mbRESTApiStarted = false; }
public void StartServer(bool pbStartOnlyLocal, int pnPort) { if (!mbRESTApiStarted) { StopServerEvent.Reset(); var loParameter = new RESTServerParams() { StartOnlyLocal = pbStartOnlyLocal, Port = pnPort }; this.CurrentServerUrl = loParameter.ToString().Replace("*", Dns.GetHostName()); ThreadPool.QueueUserWorkItem(new WaitCallback(StartRESTApi), loParameter); Thread.Sleep(this.mnWaitTime); this.OnServerStateChanged(); this.BindConnectionEvent(); } }