當前位置: 首頁>>代碼示例>>C#>>正文


C# EventHandler.GetInvocationList方法代碼示例

本文整理匯總了C#中EventHandler.GetInvocationList方法的典型用法代碼示例。如果您正苦於以下問題:C# EventHandler.GetInvocationList方法的具體用法?C# EventHandler.GetInvocationList怎麽用?C# EventHandler.GetInvocationList使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在EventHandler的用法示例。


在下文中一共展示了EventHandler.GetInvocationList方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Main

 static void Main(string[] args)
 {
     AsyncMethodCall test = new AsyncMethodCall();
     
     // Show the main thread id
     Console.WriteLine("The main thread is: {0}", Thread.CurrentThread.ManagedThreadId);
     // Register Method1 and Method2 into event
     OnEvent += new EventHandler<EventArgs>(test.Method1);
     OnEvent += new EventHandler<EventArgs>(test.Method2);
     
     // Call event handler methods asynchronize
     
     //Get the multicase delegates of event
     Delegate[] delegAry = OnEvent.GetInvocationList();
     
     //loop the delegates list
     foreach(EventHandler<EventArgs> deleg in delegAry)
     {
         deleg.BeginInvoke(null, EventArgs.Empty, null, null);
     }
     
     OnEvent -= new EventHandler<EventArgs>(test.Method1);
     OnEvent -= new EventHandler<EventArgs>(test.Method2);
     
     Console.ReadKey();
 }
開發者ID:eagles,項目名稱:demo,代碼行數:26,代碼來源:AsyncMethodCall.cs

示例2: GetInvocationListLength

 private int GetInvocationListLength(EventHandler @event)
 {
     if( @event == null )
     {
         return 0;
     }
     return @event.GetInvocationList().Length;
 }
開發者ID:shahmitulv,項目名稱:MelSamples,代碼行數:8,代碼來源:ClipboardEventPublisher.cs

示例3: SafeEventSubscribe

 /* EVENTS */
 private void SafeEventSubscribe(ref EventHandler ev, EventHandler dg)
 {
     if (ev != null)
         foreach (Delegate current in ev.GetInvocationList())
             if (current.Target == dg.Target)
                 return;
     ev += dg;
 }
開發者ID:jordymeow,項目名稱:rincevent,代碼行數:9,代碼來源:DisplayModule.cs

示例4: NotifyPageEvent

 private void NotifyPageEvent(String key, String title, EventHandler handler)
 {
     if (handler != null)
     {
         Delegate[] delegates = handler.GetInvocationList();
         foreach (EventHandler item in delegates)
         {
             try
             {
                 item.Invoke(key, EventArgs.Empty);
             }
             catch (Exception ex)
             {
                 PageLogger.RecordErrorLog(title, ex);
             }
         }
     }
 }
開發者ID:dalinhuang,項目名稱:tdcodes,代碼行數:18,代碼來源:PageSchemaMaintenance.cs

示例5: ProcessCancelableEvent

        private bool ProcessCancelableEvent(EventHandler<CCIMEKeybardEventArgs> handler, CCIMEKeybardEventArgs eventArgs)
        {
            var canceled = false;
            Delegate inFocusDelegate = null;
            var sender = TextFieldInFocus;
            foreach (var instantHandler in handler.GetInvocationList())
            {
                if (eventArgs.Cancel)
                {
                    break;
                }

                // Make sure we process all event handlers except for our focused text field
                // We need to process it at the end to give the other event handlers a chance 
                // to cancel the event from propogating to our focused text field.
                if (instantHandler.Target == sender)
                    inFocusDelegate = instantHandler;
                else
                    instantHandler.DynamicInvoke(sender, eventArgs);
            }

            canceled = eventArgs.Cancel;

            if (inFocusDelegate != null && !canceled)
                inFocusDelegate.DynamicInvoke(sender, eventArgs);

            return canceled;
        }
開發者ID:haithemaraissia,項目名稱:CocosSharp,代碼行數:28,代碼來源:IMEKeyboardImpl.cs

示例6: TriggerAnEvent

 private void TriggerAnEvent(EventHandler EH)
 {
     if (EH == null) return;
     var EventListeners = EH.GetInvocationList();
     if (EventListeners != null)
     {
         for (int index = 0; index < EventListeners.Count(); index++)
         {
             var methodToInvoke = (EventHandler)EventListeners[index];
             methodToInvoke.BeginInvoke(this, EventArgs.Empty, EndAsyncEvent, new object[] { });
         }
     }
 }
開發者ID:OptecInc,項目名稱:FocRot-Software-PC,代碼行數:13,代碼來源:HubFocRot.cs

示例7: 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

示例8: 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

示例9: FireEvent

        /// <summary>
        /// Helper method to fire events in a thread safe manner.
        /// </summary>
        /// <remarks>
        /// Checks whether subscribers implement <see cref="System.ComponentModel.ISyncronizeInvoke"/> to ensure we raise the
        /// event on the correct thread.
        /// </remarks>
        /// <param name="mainHandler">The <see cref="System.EventHandler"/> for the event to be raised.</param>
        /// <param name="e">An <see cref="System.EventArgs"/> to be passed with the event invocation.</param>
        private void FireEvent(EventHandler mainHandler, EventArgs e)
        {
            // Make sure we have some subscribers
            if (mainHandler != null)
            {
                // Get each subscriber in turn
                foreach (EventHandler handler in mainHandler.GetInvocationList())
                {
                    // Get the object containing the subscribing method
                    // If the target doesn't implement ISyncronizeInvoke, this will be null
                    ISynchronizeInvoke sync = handler.Target as ISynchronizeInvoke;

                    // Check if our target requires an Invoke
                    if (sync != null && sync.InvokeRequired)
                    {
                        // Yes it does, so invoke the handler using the target's BeginInvoke method, but wait for it to finish
                        // This is preferable to using Invoke so that if an exception is thrown its presented
                        // in the context of the handler, not the current thread
                        IAsyncResult result = sync.BeginInvoke(handler, new object[] { this, e });
                        sync.EndInvoke(result);
                    }
                    else
                    {
                        // No it doesn't, so invoke the handler directly
                        handler(this, e);
                    }
                }
            }
        }
開發者ID:wow4all,項目名稱:evemu_server,代碼行數:38,代碼來源:TrayIcon.cs

示例10: RaiseEvent

        private void RaiseEvent(EventHandler<BackgroundParserEventArgs> handler, BackgroundParserEventArgs args)
        {
            if (handler == null)
                return;

            foreach (EventHandler<BackgroundParserEventArgs> h in handler.GetInvocationList())
            {
                args.CancellationToken.ThrowIfCancellationRequested();
                h(this, args);
            }
        }
開發者ID:Samana,項目名稱:HlslTools,代碼行數:11,代碼來源:BackgroundParser.cs

示例11: AddHandler

        /// <summary>
        /// Add a handler for the given source's event.
        /// </summary>
        public static void AddHandler(object source, EventHandler<ValueChangedEventArgs> handler, PropertyDescriptor pd)
        {
            if (handler == null)
                throw new ArgumentNullException("handler");
            if (handler.GetInvocationList().Length != 1)
                throw new NotSupportedException(SR.Get(SRID.NoMulticastHandlers));

            CurrentManager.PrivateAddHandler(source, handler, pd);
        }
開發者ID:nlh774,項目名稱:DotNetReferenceSource,代碼行數:12,代碼來源:ValueChangedEventManager.cs

示例12: Execute

 static bool Execute(EventHandler<EditingManagerEventArgs> d)
 {
     if(d == null) return false;
     EditingManagerEventArgs e = new EditingManagerEventArgs();
     Delegate[] delegates = d.GetInvocationList();
     foreach(EventHandler<EditingManagerEventArgs> dg in delegates)
     {
         dg(null, e);
         if(e.Handled)
             return true;
     }
     return false;
 }
開發者ID:cyotek,項目名稱:translateclient,代碼行數:13,代碼來源:EditingManager.cs

示例13: MainFrm_Load

        private void MainFrm_Load(object sender, EventArgs e)
        {

            output("01-27-4版本這是");

            //設置當前交易日
            GPUtil.setTodayTranDay();

            //加載計劃
            //TranApi.loadTranPlan();

            //財務初始化用
            codeList = HisDataAPI.getLoadCwInfoCodes();
            //全量股票列表
            GPUtil.codes = HisDataAPI.getGpCodesFromDb();

            //將Method1和Method2注冊到事件中
            gpOnEvent += new EventHandler<EventArgs>(getYwNewHander);
            gpOnEvent += new EventHandler<EventArgs>(gpBuysTransHander);
            gpOnEvent += new EventHandler<EventArgs>(gpSellsTransHander);
            gpDelegates = gpOnEvent.GetInvocationList();

            output("初始化數據開始..");
            //初始化股票信息 
            HisDataAPI.saveTodayHisDataFromSina();
           
            //初始化下外匯          
            HisDataAPI.refreshRMBLast();          

            //關鍵字
            KeyWordAPI.loadKeyWord();

            QuShi.qsz = QuShi.getQuShiFS();
            output("趨勢值:" + QuShi.qsz);        

            //更新到買入隊列
            StaUtil.add_buys_codes();
            StaUtil.add_sells_codes();          
                                                        
        }
開發者ID:wsjiabao,項目名稱:autodz,代碼行數:40,代碼來源:MainFrm.cs

示例14: OnEvent

        protected virtual void OnEvent(EventHandler<PackageEventArgs> handler, PackageEventArgs e)
        {


            if (handler != null)
            {
                foreach (EventHandler<PackageEventArgs> singleCast in handler.GetInvocationList())
                {
                    ISynchronizeInvoke syncInvoke = singleCast.Target as ISynchronizeInvoke;
                    try
                    {
                        //This code is to make the raising of the event threadsafe with the UI thread.
                        if (syncInvoke != null && syncInvoke.InvokeRequired)
                        {
                            syncInvoke.BeginInvoke(singleCast, new object[] { this, e });
                        }
                        else
                        {
                            _log.InfoFormat("Invoking event {0}", singleCast.Method.Name);
                            singleCast(this, e);
                        }
                    }
                    catch (Exception ex)
                    {
                        if (CrashOnException)
                        {
                            throw new PacketProcessingException(ex);

                        }
                        else
                        {
                            if (e != null)
                            {
                                RaiseExceptionEncountered(ex, e.ID);
                            }
                            else
                            {
                                RaiseExceptionEncountered(ex, Guid.Empty);
                            }
                        }
                    }
                }

            }

        }
開發者ID:russjudge,項目名稱:ArtemisSBS-ProtocolSharp,代碼行數:46,代碼來源:PacketProcessing.cs


注:本文中的EventHandler.GetInvocationList方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。