Ejemplo n.º 1
0
        public void OnNewMessage()
        {
            try
            {
                var i = (ISynchronizeInvoke)this;

                // Check if the event was generated from another
                // thread and needs invoke instead
                if (i.InvokeRequired)
                {
                    var tempDelegate = new ClassOfTasks.NewMessage(OnNewMessage);
                    i.BeginInvoke(tempDelegate, null);

                    return;
                }

                // If not coming from a seperate thread
                // we can access the Windows form controls
                LoadMessages();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + @": " + ex.TargetSite);
            }
        }
Ejemplo n.º 2
0
        public void OnNewMessage()
        {
            try
            {
                var i = (ISynchronizeInvoke)this;

                // Check if the event was generated from another
                // thread and needs invoke instead
                if (i.InvokeRequired)
                {
                    var tempDelegate = new ClassOfTasks.NewMessage(OnNewMessage);
                    i.BeginInvoke(tempDelegate, null);

                    return;
                }

                // If not coming from a seperate thread
                // we can access the Windows form controls
                LoadMessages();

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + @": " + ex.TargetSite);
            }
        }