protected async override void OnStart(string[] args) { eventLog.WriteEntry("Smart Name Plate Service Started."); Logger.WriteLog("SNP.Service", "Smart Name Plate Service Started."); // Update the service state to Start Pending. //ServiceStatus serviceStatus = new ServiceStatus(); //serviceStatus.dwCurrentState = ServiceState.SERVICE_START_PENDING; //serviceStatus.dwWaitHint = 100000; //SetServiceStatus(this.ServiceHandle, ref serviceStatus); hubClient = new WindowsStatusHubClient(HUB_URL); bool isConnected = await hubClient.Connect(); if (isConnected) { Logger.WriteLog("SNP.Service", "Connection to hub complete."); } else { Logger.WriteLog("SNP.Service", "Connection to hub failed."); } // Update the service state to Running. //serviceStatus.dwCurrentState = ServiceState.SERVICE_RUNNING; //SetServiceStatus(this.ServiceHandle, ref serviceStatus); }
private async void btnStop_Click(object sender, EventArgs e) { if (client != null) { await client.Disconnect(); client = null; btnStart.Enabled = true; btnStop.Enabled = false; } }
private async void btnStart_Click(object sender, EventArgs e) { if (client == null) { client = new WindowsStatusHubClient(hubURL); await client.Connect(); btnStart.Enabled = false; btnStop.Enabled = true; } }