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


C# System.Invoke方法代码示例

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


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

示例1: AssignAllActions

    void AssignAllActions(System.Action<BaseEventData> pressedAction,
						  System.Action<BaseEventData> releasedAction,
						  ref EventTrigger trigger)
    {
        EventTrigger.Entry entry1 = new EventTrigger.Entry();

        entry1.eventID = EventTriggerType.PointerDown;
        entry1.callback.AddListener(eventData => pressedAction.Invoke(eventData));

        trigger.triggers.Add(entry1);

        EventTrigger.Entry entry2 = new EventTrigger.Entry();

        entry2.eventID = EventTriggerType.PointerUp;
        entry2.callback.AddListener(eventData => releasedAction.Invoke(eventData));

        trigger.triggers.Add(entry2);

        EventTrigger.Entry entry3 = new EventTrigger.Entry();

        entry3.eventID = EventTriggerType.PointerExit;
        entry3.callback.AddListener(eventData => releasedAction.Invoke(eventData));

        trigger.triggers.Add(entry3);
    }
开发者ID:rbrt,项目名称:Breaker,代码行数:25,代码来源:AssignActionsToInputs.cs

示例2: QueueUserWorkItem

 public static void QueueUserWorkItem(System.Threading.WaitCallback callback)
 {
     if (Pool != null)
     {
         Pool.QueueWorkItem(state => { callback.Invoke(state); return null; });
     }
     else
     {
         System.Threading.ThreadPool.QueueUserWorkItem(state => callback.Invoke(state));
     }
 }
开发者ID:jakzodiac,项目名称:libopenmetaverse,代码行数:11,代码来源:WorkPool.cs

示例3: DelayExecute

        public static void DelayExecute(System.Action callback, int msDelay, bool onUIThread = true)
        {
            Thread t = new Thread(delegate() {
                Thread.Sleep(msDelay);

                if (onUIThread)
                    Caliburn.Micro.Execute.OnUIThread(() => callback.Invoke());
                else
                    callback.Invoke();
            });
            t.Start();
        }
开发者ID:jserna-arl,项目名称:LIMSv2,代码行数:12,代码来源:AppLib.cs

示例4: Invoke

        public static object Invoke(System.Windows.Forms.Control obj, string methodName, params object[] paramValues)
        {
            Delegate del = null;
            string key = obj.GetType().Name + "." + methodName;
            Type tp;
            lock (methodLookup)
            {
                if (methodLookup.Contains(key))
                    tp = (Type)methodLookup[key];
                else
                {
                    Type[] paramList = new Type[obj.GetType().GetMethod(methodName).GetParameters().Length];
                    int n = 0;
                    foreach (ParameterInfo pi in obj.GetType().GetMethod(methodName).GetParameters()) paramList[n++] = pi.ParameterType;
                    TypeBuilder typeB = builder.DefineType("Del_" + obj.GetType().Name + "_" + methodName, TypeAttributes.Class | TypeAttributes.AutoLayout | TypeAttributes.Public | TypeAttributes.Sealed, typeof(MulticastDelegate), PackingSize.Unspecified);
                    ConstructorBuilder conB = typeB.DefineConstructor(MethodAttributes.HideBySig | MethodAttributes.SpecialName | MethodAttributes.RTSpecialName, CallingConventions.Standard, new Type[] { typeof(object), typeof(IntPtr) });
                    conB.SetImplementationFlags(MethodImplAttributes.Runtime);
                    MethodBuilder mb = typeB.DefineMethod("Invoke", MethodAttributes.Public | MethodAttributes.Virtual | MethodAttributes.HideBySig, obj.GetType().GetMethod(methodName).ReturnType, paramList);
                    mb.SetImplementationFlags(MethodImplAttributes.Runtime);
                    tp = typeB.CreateType();
                    methodLookup.Add(key, tp);
                }
            }

            del = MulticastDelegate.CreateDelegate(tp, obj, methodName);
            return obj.Invoke(del, paramValues);
        }
开发者ID:etos,项目名称:wrox-sfv,代码行数:27,代码来源:SafeInvoke.cs

示例5: Invoke

 /// <summary>
 ///   Invokes the given action on the UI thread - if the current thread is the UI thread this will just invoke the action directly on
 ///   the current thread so it can be safely called without the calling method being aware of which thread it is on.
 /// </summary>
 public static void Invoke(System.Action action)
 {
     if (Dispatcher.CheckAccess())
         action.Invoke();
     else
         Dispatcher.BeginInvoke(action);
 }
开发者ID:toolsche,项目名称:BusCon,代码行数:11,代码来源:UIThread.cs

示例6: Invoke

		public static void Invoke(System.Windows.Forms.Control con, InvokeDelegate callback) {
			if (con.InvokeRequired) {
				con.Invoke(callback);
			} else {
				callback();
			}
		}
开发者ID:GodLesZ,项目名称:svn-dump,代码行数:7,代码来源:InvokeHelper.cs

示例7: Invoke

		public static void Invoke(System.Windows.Forms.Control Control, InvokeDelegate Delegate) {
			if (Control.InvokeRequired) {
				Control.Invoke(Delegate);
			} else {
				Delegate();
			}
		}
开发者ID:GodLesZ,项目名称:svn-dump,代码行数:7,代码来源:InvokeHelper.cs

示例8: GetInstance

        public override object GetInstance(System.Reflection.ConstructorInfo constructor, object[] parameters = null)
        {
            if (cache.ContainsKey(constructor.DeclaringType))
            {
                return cache[constructor.DeclaringType];
            }

            var dependencies = constructor.GetParameters();
            if (dependencies.Count() == 0)
            {
                var instance = Activator.CreateInstance(constructor.DeclaringType);
                cache.Add(constructor.DeclaringType, instance);

                return instance;
            }
            else
            {
                if (parameters == null || parameters.Count() != dependencies.Count())
                {
                    throw new Exception("Incorrect number of parameters to invoke instance.");
                }

                var instance = constructor.Invoke(parameters);
                cache.Add(constructor.DeclaringType, instance);

                return instance;
            }
        }
开发者ID:stesta,项目名称:Injectamundo,代码行数:28,代码来源:SingletonLifestyle.cs

示例9: Authenticate

 public void Authenticate(System.Action<bool> callback, bool silent)
 {
   LogUsage();
   if (callback != null)
     {
       callback.Invoke(false);
     }
 }
开发者ID:timnlupo,项目名称:Gooth,代码行数:8,代码来源:DummyClient.cs

示例10: UpdatePbar

 public static void UpdatePbar(System.Windows.Forms.ProgressBar name, int step)
 {
     if (name.InvokeRequired)
     {
         object[] params_list = new object[] { name, step };
         name.Invoke(new UpdateProgressBar(UpdatePbar), params_list);
     }
     else { name.Increment(step); }
 }
开发者ID:Gevil,项目名称:Projects,代码行数:9,代码来源:Creature.cs

示例11: SetText

 public static void SetText(System.Windows.Forms.TextBox ctrl, string text)
 {
     if (ctrl.InvokeRequired)
     {
         object[] params_list = new object[] { ctrl, text };
         ctrl.Invoke(new SetTextDelegate(SetText), params_list);
     }
     else { ctrl.AppendText(text); }
 }
开发者ID:Gevil,项目名称:Projects,代码行数:9,代码来源:Creature.cs

示例12: RunTestCase

 internal void RunTestCase(System.Reflection.MethodInfo met)
 {
     var testInstance = Activator.CreateInstance(this.testCaseType);
     if (this.setupMethod != null)
     {
         this.setupMethod.Invoke(testInstance, null);
     }
     met.Invoke(testInstance, null);
 }
开发者ID:CompilerKit,项目名称:Espresso,代码行数:9,代码来源:Program.cs

示例13: RunTest

        public void RunTest (Test test, System.Reflection.MethodInfo method)
        {
            var startTime = DateTime.Now;

            test.Setup ();
            var attributes = (TestAttribute[])method.GetCustomAttributes (typeof(TestAttribute), false);

            if (attributes[0].Async) {
                try {
                    method.Invoke (test, new object[] { (AsyncCallback)(result =>
                    {
                        var t = (Test)((object[])result.AsyncState)[0];
                        var m = (System.Reflection.MethodInfo)((object[])result.AsyncState)[1];
                        var s = (DateTime)((object[])result.AsyncState)[2];

                        t.TearDown ();

                        if (OnTestFinished != null)
                        {
                            OnTestFinished (t, m, DateTime.Now - s, null);
                        }
                    }), new object[] { test, method, startTime } });
                } catch (Exception ex)
                {
                    if (OnTestFinished != null)
                    {
                        OnTestFinished(test, method, DateTime.Now - startTime, ex);
                    }
                }
            } else {
                Exception ex = null;
                try {
                    method.Invoke (test, null);
                } catch (Exception e)
                {
                    ex = e;
                }
                test.TearDown ();

                if (OnTestFinished != null) {
                    OnTestFinished (test, method, DateTime.Now - startTime, ex);
                }
            }
        }
开发者ID:hallvar,项目名称:Joddes.CS,代码行数:44,代码来源:TestRunner.cs

示例14: Invoke

        public virtual object Invoke(object proxy, System.Reflection.MethodInfo method, params object[] arguments)
        {
            PreInvoke(proxy, method, arguments);

            object returnValue = method.Invoke( Target, arguments );

            PostInvoke(proxy, method, ref returnValue, arguments);

            return returnValue;
        }
开发者ID:BackupTheBerlios,项目名称:dpml-svn,代码行数:10,代码来源:StandardInvocationHandler.cs

示例15: Invoke

            public object Invoke(object target, System.Reflection.MethodInfo method, params object[] parameters)
            {
                Console.WriteLine("before call:"+method.Name);

                object result = method.Invoke(target , parameters);

                Console.WriteLine("after call:" + method.Name);

                return result;
            }
开发者ID:netcasewqs,项目名称:nlite,代码行数:10,代码来源:ProxyTest.cs


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