/// <summary> /// Completes an asynchronous get status request and updates the control. /// </summary> private void OnGetStatus(IAsyncResult result) { if (InvokeRequired) { BeginInvoke(new AsyncCallback(OnGetStatus), result); return; } try { OpcGetStatusDelegate callback = (OpcGetStatusDelegate)result.AsyncState; OpcServerStatus status = callback.EndInvoke(result); ShowPanels = true; InfoPN.Text = status.VendorInfo; StatePN.Text = (status.StatusInfo == null)?status.ServerState.ToString():status.StatusInfo; TimePN.Text = status.CurrentTime.ToString(); } catch (Exception e) { ShowPanels = false; Text = e.Message; } }
/// <summary> /// Called when the update timer expires - begins a get status request. /// </summary> private void UpdateTimer_Tick(object sender, System.EventArgs e) { try { OpcGetStatusDelegate callback = new OpcGetStatusDelegate(m_server.GetServerStatus); callback.BeginInvoke(new AsyncCallback(OnGetStatus), callback); } catch (Exception exception) { ShowPanels = false; Text = exception.Message; } }