/// <summary> /// The main entry point for the application. /// </summary> static void Main() { OutProc outProc = new OutProc(); int result = (int)EnumResultCode.S_OK; try { outProc.CreateOpcClient(); OpcClient opcClient = outProc.OpcClient; // initialize the client instance if (!ResultCode.SUCCEEDED(opcClient.Initialize())) { opcClient = null; return; } // end if OpcForm opcForm = new OpcForm(); // initialize the AE client simulation result |= opcClient.InitializeAeObjects(); opcClient.SetForm(opcForm); opcForm.SetOutProc(outProc); System.Windows.Forms.Application.Run(opcForm); opcClient.Terminate(); opcClient = null; } catch (Exception exc) { MessageBox.Show(exc.ToString()); } // end try...catch } // end Main
} // end constructor public void SetOutProc(OutProc anOutProc) { try { m_outProc = anOutProc; m_opcClient = m_outProc.OpcClient; m_session = m_opcClient.GetSession(); m_subscription = m_opcClient.GetSubscription(); m_executionOptions = m_opcClient.GetExecutionOptions(); } catch (Exception exc) { MessageBox.Show(exc.ToString()); } // end try...catch }