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


C# EventHandler.Invoke方法代码示例

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


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

示例1: Main

 static void Main()
 {
     _show += new EventHandler(Cat);
     _show += new EventHandler(Dog);
     _show += new EventHandler(Mouse);
     _show.Invoke();
 }
开发者ID:RoykoSerhiy,项目名称:visualStudio_projects,代码行数:7,代码来源:Program.cs

示例2: PosTest1

    public bool PosTest1()
    {
        bool retVal = true;

        String temp = TestLibrary.Generator.GetString(-55, false, 1, 255);

        TestLibrary.TestFramework.BeginScenario("PosTest1:invoke the method");
        try
        {
            HelperEvent helperEvent = new HelperEvent();

            EventHandler<HelperArgs> eventHandler = new EventHandler<HelperArgs>(setMessage);

            eventHandler.Invoke(helperEvent,new HelperArgs(temp));

            if (!helperArgs.message.Equals(temp))
            {
                TestLibrary.TestFramework.LogError("001", "ExpectedValue(true) !=ActualValue(false)");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("002", "Unexpected exception:" + e);
            retVal = false;
        }
        return retVal;
    }
开发者ID:l1183479157,项目名称:coreclr,代码行数:28,代码来源:eventhandlerinvoke.cs

示例3: ProcessCSS

        public void ProcessCSS(string filename, EventHandler e)
        {
            if (!_cssObjects.ContainsKey(filename))
            {
                string filePath = CssPath + filename + ".css?" + Date.Now.GetMilliseconds().ToString();

                //jQuery.Get(filePath, delegate(object css)
                //{
                //    string current = jQuery.Select("style").GetHtml();
                //    jQuery.Select("style").Html(current + (string)css);
                //    e.Invoke(this, null);
                //});

                Element fileref = Document.CreateElement("link");
                fileref.SetAttribute("rel", "stylesheet");
                fileref.SetAttribute("type", "text/css");
                fileref.SetAttribute("href", CssPath + filename + ".css?" + Date.Now.GetMilliseconds().ToString());
                Document.GetElementsByTagName("head")[0].AppendChild(fileref);
                _cssObjects.Add(filename, fileref);
                //_loadedCss.Add(filename);
                if (e != null)
                {
                    e.Invoke(this, null);
                }

            }
            else
            {
                Logging.Debug("Already Processed CSS File", new object[] { filename });
                if (e != null)
                {
                    e.Invoke(this, null);
                }
            }
        }
开发者ID:Azerothian,项目名称:PandoraJS,代码行数:35,代码来源:FileLoader.cs

示例4: GetFriends

 public static void GetFriends(EventHandler<FriendsListEventArgs> callback)
 {
     var serializer = new Hammock.Serialization.HammockDataContractJsonSerializer();
     RestClient client = new RestClient
     {
         Authority = baseUrl,
         Timeout = new TimeSpan(0, 0, 0, _timeOut),
         Serializer = serializer,
         Deserializer = serializer
     };
     RestRequest request = new RestRequest
                               {
                                   Path = "GetFriends" + "?timestamp=" + DateTime.Now.Ticks.ToString(),
                                   Timeout = new TimeSpan(0, 0, 0, _timeOut)
                               };
     friendscallback = callback;
     try
     {
         client.BeginRequest(request, new RestCallback<List<Friend>>(GetFriendsCallback));
     }
     catch (Exception ex)
     {
         friendscallback.Invoke(null, new FriendsListEventArgs() { Friends = null, Error = new WebException("Communication Error!", ex) });
     }
     
 }
开发者ID:253525306,项目名称:myfriendsaround,代码行数:26,代码来源:ServiceAgent.cs

示例5: ShowWindow

        /// <summary>
        /// Displays content in a window
        /// </summary>
        /// <param name="windowTitle">Title text shown in window</param>
        /// <param name="windowContents">Contents of the window</param>        
        /// <param name="isModal">Determines wheter the window is modal or not</param>
        /// <param name="onClosingHandler">Event handler invoked when window is closing, and can be handled to cancel window closure</param>
        /// <param name="windowType">The type of the window</param>
        /// <param name="onClosedHandler">Event handler invoked when window is closed</param>
        /// <param name="top">The distance from the top of the application at which to position the window</param>
        /// <param name="left">The distance from the left of the application at which to position the window</param>
        /// <returns>The window</returns>
        public object ShowWindow(string windowTitle, FrameworkElement windowContents, bool isModal = false, 
            EventHandler<CancelEventArgs> onClosingHandler = null, EventHandler onClosedHandler = null, 
            WindowType windowType = WindowType.Floating, double? top = null, double? left = null)            
        {                        
            if (windowContents == null)
                throw new ArgumentNullException("windowContents");

            int hashCode = windowContents.GetHashCode();
            FloatingWindow floatingWindow = null;
            if (!m_FloatingWindows.TryGetValue(hashCode, out floatingWindow))
            {
                // not existing yet
                floatingWindow = new FloatingWindow()
                {
                    Title = windowTitle ?? string.Empty,
                };

                switch (windowType)
                {
                    case WindowType.Floating:
                if (FloatingWindowStyle != null)
                    floatingWindow.Style = FloatingWindowStyle;
                        break;
                    case WindowType.DesignTimeFloating:
                        if (DesignTimeWindowStyle != null)
                            floatingWindow.Style = DesignTimeWindowStyle;
                        else if (FloatingWindowStyle != null) // fallback to FloatingWindowStyle
                            floatingWindow.Style = FloatingWindowStyle;
                        break;
                }

                floatingWindow.Closed += (o, e) =>
                {
                    if (onClosedHandler != null)
                        onClosedHandler.Invoke(o, e);

                    m_FloatingWindows.Remove(hashCode);

                    if (floatingWindow != null)
                        floatingWindow.Content = null;
                };

                if (onClosingHandler != null)
                    floatingWindow.Closing += onClosingHandler;
                floatingWindow.Content = windowContents;
                m_FloatingWindows.Add(hashCode, floatingWindow);
            }


            if (top != null)
                floatingWindow.VerticalOffset = (double)top;

            if (left != null)
                floatingWindow.HorizontalOffset = (double)left;

            floatingWindow.Show(isModal);

            return floatingWindow;
        }
开发者ID:konglingjie,项目名称:arcgis-viewer-silverlight,代码行数:71,代码来源:WindowManager.cs

示例6: DownloadIfNotExists

        public void DownloadIfNotExists(EventHandler callback)
        {
            StreamReady += callback;
            FilesToDownload = new List<string>();
            foreach (string file in Filenames)
            {
#if !SILVERLIGHT
                if (!File.Exists(file))
#else
                if (!IsolatedStorageFile.GetUserStoreForApplication().FileExists(file))
#endif
                    FilesToDownload.Add(file);
            }

            if (FilesToDownload.Count == 0)
            {
                //We have all the files, just fire the ready event
                if (StreamReady != null) StreamReady.Invoke(this, EventArgs.Empty);
            }
            else
            {
                //We need to download at least one of the files
#if !SILVERLIGHT
                try
                {
                    ExtractXmlFiles(File.Open(@"ClientBin\\DefaultDataFiles.zip", FileMode.Open));
                }
                catch (Exception error)
                {
                    (App.Current as App).WriteLoadProgress(error.Message);
                }
                if (StreamReady != null) StreamReady.Invoke(this, EventArgs.Empty);
#else
                Uri url = new Uri("DefaultDataFiles.zip", UriKind.Relative);

                WebClient client = new WebClient();
                client.OpenReadCompleted += new OpenReadCompletedEventHandler(client_OpenReadCompleted);
                client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged);
                client.OpenReadAsync(url);

                UpdateProgress(0, "Downloading default data files...");
#endif
            }
        }
开发者ID:LucasPeacecraft,项目名称:rawr,代码行数:44,代码来源:FileUtils.cs

示例7: Main

        static void Main()
        {
            myDelegate del = new myDelegate(Timer.ShowTime);

            Show = new EventHandler(del);

            for (int i = 0; i < 60; i++)
            {
                Show.Invoke();
            }
        }
开发者ID:quela,项目名称:myprojects,代码行数:11,代码来源:ShowEvetns.cs

示例8: Main

        static void Main(string[] args)
        {
            _printInfo += new EventHandler(Name);
            _printInfo += new EventHandler(Address);
            _printInfo += new EventHandler(City);
            _printInfo += new EventHandler(State);

            _printInfo.Invoke();

            Console.ReadKey();
        }
开发者ID:NMC-CIT255,项目名称:Demo_Events_PointChanged,代码行数:11,代码来源:Program.cs

示例9: Main

    static void Main()
    {
    // Add event handlers to Show event.
    _show += new EventHandler(Dog);
    _show += new EventHandler(Cat);
    _show += new EventHandler(Mouse);
    _show += new EventHandler(Mouse);

    // Invoke the event.
    _show.Invoke();
    }
开发者ID:mortezabarzkar,项目名称:SharpNative,代码行数:11,代码来源:Events.cs

示例10: EventOnce

        // methods
        /// <summary>
        /// Events the once.
        /// </summary>
        /// <param name="eventObject">The event object</param>
        /// <param name="eventMember">The event member</param>
        /// <param name="handler">The handler</param>
        public static void EventOnce(object eventObject, string eventMember, EventHandler handler)
        {
            EventInfo eventInfo = eventObject.GetType().GetEvent(eventMember);
            EventHandler tempEventHandler = null;

            tempEventHandler = (sender, e) =>
            {
                handler.Invoke(null, new EventArgs());
                eventInfo.RemoveEventHandler(eventObject, tempEventHandler);
            };
            eventInfo.AddEventHandler(eventObject, tempEventHandler);
        }
开发者ID:eserozvataf,项目名称:tasslehoff,代码行数:19,代码来源:EventHelpers.cs

示例11: PublishEvent

 private void PublishEvent(EventHandler handler, RAEventArgs e)
 {
     try
     {
         if (handler != null)
             handler.Invoke(null, e);
     }
     catch (Exception /*ex*/)
     {
         //Debug.Fail("Cannot call event: " + ex.ToString());
     }
 }
开发者ID:ddugovic,项目名称:RASuite,代码行数:12,代码来源:RAEventService.cs

示例12: GetPeopleAsync

 public void GetPeopleAsync(EventHandler<ServiceResult<IList<Person>>> callback)
 {
     BackgroundWorker bw = new BackgroundWorker();
     bw.DoWork += (o, e) =>
         {
             e.Result = GetPeople();
         };
     bw.RunWorkerCompleted += (o, e) =>
         {
             callback.Invoke(this, new ServiceResult<IList<Person>>((IList<Person>)e.Result));
         };
     bw.RunWorkerAsync();
 }
开发者ID:ProductiveEngine,项目名称:KnowledgeBase,代码行数:13,代码来源:PersonService.cs

示例13: AsyncActionCallBack

 public static void AsyncActionCallBack(CCAction p_Action,EventHandler CallBack)
 {
     System.Threading.ThreadPool.QueueUserWorkItem
         ((obj) =>
         {
             while (true)
             {
                 System.Threading.Thread.Sleep(100);
                 if (p_Action.isDone())
                 {
                     CallBack.Invoke(null,new EventArgs());
                     break;
                 }
             }
         });
 }
开发者ID:tianjing,项目名称:SayWordByPicture,代码行数:16,代码来源:ActionHelper.cs

示例14: SetLoadMore

 public static void SetLoadMore(UIElement element, EventHandler value)
 {
     element.SetValue(LoadMoreProperty, value);
     var sv = element as ScrollViewer;
     if (sv != null)
     {
         sv.ViewChanged += (sender, args) =>
         {
             var verticalOffsetValue = sv.VerticalOffset;
             var maxVerticalOffsetValue = sv.ExtentHeight - sv.ViewportHeight;
             if (maxVerticalOffsetValue < 0 || Math.Abs(verticalOffsetValue - maxVerticalOffsetValue) < 1.0)
             {
                     
                 value.Invoke(sv, EventArgs.Empty);
             }
         };
     }
 }
开发者ID:Korshunoved,项目名称:Win10reader,代码行数:18,代码来源:ScrollViewerIncremental.cs

示例15: DisposableSavingChangesListener

        /// <summary>
        /// 
        /// </summary>
        /// <param name="context">
        /// The object context in which the SavingChanges event will be listened on
        /// </param>
        /// <param name="eventHandler">
        /// The event handler to call when the SavingChanges event is triggered
        /// </param>
        public DisposableSavingChangesListener(ObjectContext context, EventHandler eventHandler)
        {
            // NOTE: We wrap the event handler in our own event handler. The reason for this is so that
            //       we can perform an object context check prior to calling the real event handler,
            //       insuring that we don't fire off for the wrong context.
            this.context = context;
            this.handler = (sender, args) =>
            {
                // If our context didn't trigger this event, ignore it.
                // We are only interested in events raised from our context
                if (sender != context)
                    return;

                // Call the child event handler
                if (eventHandler != null)
                    eventHandler.Invoke(sender, args);
            };

            // Register the event handler
            if (context != null)
                context.SavingChanges += handler;
        }
开发者ID:NiSHoW,项目名称:FrameLogCustom,代码行数:31,代码来源:DisposableSavingChangesListener.cs


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