///  <summary>
        ///  Enables accessing a form from another thread
        ///  </summary>
        ///
        ///  <param name="action"> A String that names the action to perform on the form. </param>
        ///  <param name="textToDisplay"> Text that the form displays or uses for
        ///  another purpose. Actions that don't use text ignore this parameter. </param>

        private void MyMarshalToForm(String action, String textToDisplay)
        {
            object[]      args = { action, textToDisplay };
            MarshalToForm MarshalToFormDelegate = null;

            try
            {
                //  The AccessForm routine contains the code that accesses the form.

                MarshalToFormDelegate = new MarshalToForm(AccessForm);

                //  Execute AccessForm, passing the parameters in args.

                base.Invoke(MarshalToFormDelegate, args);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#2
0
        ///  <summary>
        ///  Enables accessing a form from another thread 
        ///  </summary>
        ///  
        ///  <param name="action"> A String that names the action to perform on the form. </param>
        ///  <param name="textToDisplay"> Text that the form displays or uses for 
        ///  another purpose. Actions that don't use text ignore this parameter. </param>
        private void MyMarshalToForm(String action, String textToDisplay)
        {
            object[] args = { action, textToDisplay };
            MarshalToForm MarshalToFormDelegate = null;

            try
            {
                //  The AccessForm routine contains the code that accesses the form.

                MarshalToFormDelegate = new MarshalToForm(AccessForm);

                //  Execute AccessForm, passing the parameters in args.

                base.Invoke(MarshalToFormDelegate, args);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }