/** ** ** MinCor-C# -Demo ** CORBA Solution for .Net with C# Language mapping ** Version: 1.0 ** ** Copyright: ** Middsol GmbH, Hamburg ** Germany 2004 ** www.Middsol.com ** info@Middsol.de ** */ using System; using System.Drawing; using System.Collections; using System.Windows.Forms; using System.Data; namespace HelloSrv { public interface IFrm { void writeLog( string a_strMsg); } public class FrmHelloSrv : System.Windows.Forms.Form, IFrm { private System.Windows.Forms.ListBox lbLog; private System.Windows.Forms.Button btEnd; private System.Windows.Forms.MainMenu mainMenu1; private System.Windows.Forms.Timer tiUpdate; private ServerImpl m_oServerImpl = null; public System.Collections.Queue m_oMsgQueue; private System.Object m_oSync; public FrmHelloSrv() { InitializeComponent(); m_oSync = new System.Object(); m_oMsgQueue = new System.Collections.Queue(); m_oServerImpl = new ServerImpl( this); } protected override void Dispose( bool disposing ) { if( m_oServerImpl != null) { m_oServerImpl.destroy(); } base.Dispose( disposing ); } #region Vom Windows Form-Designer generierter Code /// /// Erforderliche Methode für die Designerunterstützung. /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden. /// private void InitializeComponent() { this.mainMenu1 = new System.Windows.Forms.MainMenu(); this.lbLog = new System.Windows.Forms.ListBox(); this.btEnd = new System.Windows.Forms.Button(); this.tiUpdate = new System.Windows.Forms.Timer(); // // lbLog // this.lbLog.Location = new System.Drawing.Point(24, 32); this.lbLog.Size = new System.Drawing.Size(192, 156); // // btEnd // this.btEnd.Location = new System.Drawing.Point(144, 216); this.btEnd.Size = new System.Drawing.Size(80, 32); this.btEnd.Text = "End"; this.btEnd.Click += new System.EventHandler(this.btEnd_Click); // // tiUpdate // this.tiUpdate.Enabled = true; this.tiUpdate.Tick += new System.EventHandler(this.tiUpdate_Tick); // // FrmHelloSrv // this.Controls.Add(this.lbLog); this.Controls.Add(this.btEnd); this.Menu = this.mainMenu1; this.Text = "HelloSrv"; } #endregion static void Main() { Application.Run(new FrmHelloSrv()); } private void btEnd_Click(object sender, System.EventArgs e) { if( m_oServerImpl != null) m_oServerImpl.destroy(); Application.Exit(); } private void tiUpdate_Tick(object sender, System.EventArgs e) { System.Threading.Monitor.Enter( m_oSync); while( m_oMsgQueue.Count > 0) { showMessage( (string)m_oMsgQueue.Dequeue()); } System.Threading.Monitor.Exit( m_oSync); } private void showMessage( string strMsg) { int iIndex = this.lbLog.Items.Add( strMsg); lbLog.SelectedIndex = iIndex; } public void writeLog( string a_strMsg) { System.Threading.Monitor.Enter( m_oSync); m_oMsgQueue.Enqueue( a_strMsg); System.Threading.Monitor.Exit( m_oSync); } } }