当前位置: 首页>>代码示例>>C#>>正文


C# EventHandler.DynamicInvoke方法代码示例

本文整理汇总了C#中EventHandler.DynamicInvoke方法的典型用法代码示例。如果您正苦于以下问题:C# EventHandler.DynamicInvoke方法的具体用法?C# EventHandler.DynamicInvoke怎么用?C# EventHandler.DynamicInvoke使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EventHandler的用法示例。


在下文中一共展示了EventHandler.DynamicInvoke方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ConnectAsync

        public bool ConnectAsync(EventHandler<SocketAsyncEventArgs> onCompletion)
        {
            if (socket.Connected)
            {
                // already connected, just invoke the 'on completion' event.
                onCompletion.DynamicInvoke(null, null);
                return false; // operation not pending - return synchronously
            }
            else
            {

                SocketAsyncEventArgs socketEventArgs = new SocketAsyncEventArgs()
                {
                    RemoteEndPoint = new IPEndPoint(this.hostaddress, this.port)
                };

                socketEventArgs.Completed += onCompletion;

                return socket.ConnectAsync(socketEventArgs);
            }
        }
开发者ID:vstrien,项目名称:KOCus,代码行数:21,代码来源:SocketAsync.cs

示例2: EventFire

        private void EventFire(EventHandler evntHndlr, EventArgs ea)
        {
            if (evntHndlr == null)
                return;

            int i = 0;
            foreach (Delegate del in evntHndlr.GetInvocationList())
            {
                try
                {
                    ISynchronizeInvoke syncr = del.Target as ISynchronizeInvoke;
                    if (syncr == null)
                    {
                        evntHndlr.DynamicInvoke(new object[] { this, ea });
                    }
                    else if (syncr.InvokeRequired)
                    {
                        syncr.Invoke(evntHndlr, new object[] { this, ea });
                    }
                    else
                    {
                        evntHndlr.DynamicInvoke(new object[] { this, ea });
                    }
                }
                catch (Exception ex)
                {
                    //
                    // Eat the exception
                    //
                    Trace.WriteLine(string.Format("SplitButton failed delegate call {0}.  Exception {1}", i, ex.ToString()));
                }

                ++i;
            }
        }
开发者ID:Dason1986,项目名称:Lib,代码行数:35,代码来源:SplitButton.cs

示例3: EventFire

        private void EventFire(EventHandler evntHndlr, EventArgs ea)
        {
            // Make sure that the handler has methods bound to it.
            if (evntHndlr == null)
                return;

            // Iterate through the methods attached to the handler:
            // 1	If an exception is thrown, swallow it
            // 2	Make sure that Contorl-Invoke is used if appropriate.
            int i = 0;
            foreach (Delegate del in evntHndlr.GetInvocationList())
            {
                try
                {
                    //
                    //	syncr is more than likely a control through it could be
                    // any class that supports ISynchronizeInvoke interface
                    //
                    ISynchronizeInvoke syncr = del.Target as ISynchronizeInvoke;
                    if (syncr == null)
                    {
                        //
                        // If del.Target does not represent a control (or a class that
                        // requires synchronization) then invoke the event as usual.
                        //
                        evntHndlr.DynamicInvoke(new object[] { this, ea });
                    }
                    else if (syncr.InvokeRequired)
                    {
                        //
                        // syncr represents a control and invoke is required so
                        // use the syncr's invoke (or Control-invoke).
                        //
                        syncr.Invoke(evntHndlr, new object[] { this, ea });
                    }
                    else
                    {
                        //
                        // syncr represents a control but invoke on the control
                        // is not required.  This means that we are on the UI thread
                        // of that control.
                        //
                        evntHndlr.DynamicInvoke(new object[] { this, ea });
                    }
                }
                catch (Exception ex)
                {
                    //
                    // Eat the exception
                    //
                    System.Diagnostics.Debug.WriteLine(string.Format("SplitButton failed delegate call {0}.  Exception {1}", i, ex.ToString()));
                }

                ++i;
            }
        }
开发者ID:sunpander,项目名称:VSDT,代码行数:56,代码来源:SplitButton.cs


注:本文中的EventHandler.DynamicInvoke方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。