本文整理汇总了C#中System.Delegate.GetInvocationList方法的典型用法代码示例。如果您正苦于以下问题:C# Delegate.GetInvocationList方法的具体用法?C# Delegate.GetInvocationList怎么用?C# Delegate.GetInvocationList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Delegate
的用法示例。
在下文中一共展示了Delegate.GetInvocationList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ValidateCallback
// Token: 0x06001860 RID: 6240
// RVA: 0x00014E5C File Offset: 0x0001305C
private static void ValidateCallback(Delegate delegate_0)
{
if (delegate_0 != null && delegate_0.GetInvocationList().Length > 1)
{
throw new NotSupportedException("SmartThreadPool doesn't support delegates chains");
}
}
示例2: Invoke
/// <summary>
/// Invokes a method delegate asynchrounously and thread safe.
/// </summary>
/// <param name="method">The delegate method to invoke</param>
/// <param name="args">The arguments passed to the delegate.</param>
public static void Invoke(Delegate method, object[] args)
{
if (method != null)
{
foreach (Delegate handler in method.GetInvocationList())
{
if (handler.Target is Control)
{
Control target = handler.Target as Control;
if (target.IsHandleCreated)
{
target.BeginInvoke(handler, args);
}
}
else if (handler.Target is ISynchronizeInvoke)
{
ISynchronizeInvoke target = handler.Target as ISynchronizeInvoke;
target.BeginInvoke(handler, args);
}
else
{
handler.DynamicInvoke(args);
}
}
}
}
示例3: AddTaskDelay
private static void AddTaskDelay(Delegate ev, object[] paramArray, int time)
{
System.Threading.Thread.Sleep(time);
bool bFired;
if (ev != null)
{
foreach (Delegate singleCast in ev.GetInvocationList())
{
bFired = false;
try
{
ISynchronizeInvoke syncInvoke = (ISynchronizeInvoke)singleCast.Target;
if (syncInvoke != null && syncInvoke.InvokeRequired)
{
bFired = true;
syncInvoke.BeginInvoke(singleCast, paramArray);
}
else
{
bFired = true;
singleCast.DynamicInvoke(paramArray);
}
}
catch (Exception)
{
if (!bFired)
singleCast.DynamicInvoke(paramArray);
}
}
}
}
示例4: GetDelegateList
public static Delegate[] GetDelegateList(Delegate del)
{
if(del == null) {
throw new ArgumentNullException("del");
}
return del.GetInvocationList();
}
示例5: DisplayDelegateInfo
public static void DisplayDelegateInfo(Delegate del)
{
foreach (var item in del.GetInvocationList())
{
Console.WriteLine("Method Name {0}", del.Method);
Console.WriteLine("Type Name {0}", del.Target);
}
}
示例6: ReadDelegate
private void ReadDelegate( Delegate delObj )
{
foreach (Delegate del in delObj.GetInvocationList())
{
Console.WriteLine("Method {0}", del.Method);
Console.WriteLine("Target {0}", del.Target);
}
}
示例7: DisplayDelegateInfo
static void DisplayDelegateInfo(Delegate delObj)
{
foreach (Delegate d in delObj.GetInvocationList())
{
Console.WriteLine("Method name: {0}", d.Method);
Console.WriteLine("Type name: {0}", d.Target);
}
}
示例8: GetDelegateDetails
public static void GetDelegateDetails(Delegate d)
{
foreach (Delegate dg in d.GetInvocationList())
{
Console.WriteLine("Type is {0}",dg.GetType());
Console.WriteLine("Method is {0}",dg.Method);
Console.WriteLine("target is {0}",dg.Target);
}
}
示例9: Handle
private static void Handle(Delegate del, PacketHandlerEventArgs args, params object[] parameters)
{
if (del != null)
foreach (Delegate d in del.GetInvocationList())
{
bool? result = (bool?)d.Method.Invoke(d.Target, parameters);
if (result.HasValue)
args.Block = result.Value;
}
}
示例10: DelegateMetadata
/// <summary>
/// Initializes a new instance.
/// </summary>
/// <param name="d">The delegate the info object should be created for.</param>
public DelegateMetadata(Delegate d)
{
Requires.NotNull(d, nameof(d));
_delegate = d;
_delegateType = d.GetType();
var list = d.GetInvocationList();
_targets = list.Select(info => info.Target).ToArray();
_methods = list.Select(info => info.Method).ToArray();
}
示例11: Cast
private static dynamic Cast(Delegate source, Type type)
{
Delegate[] delegates = source.GetInvocationList();
if (delegates.Length == 1)
return Delegate.CreateDelegate(type,
delegates[0].Target, delegates[0].Method);
Delegate[] delegatesDest = new Delegate[delegates.Length];
for (int nDelegate = 0; nDelegate < delegates.Length; nDelegate++)
delegatesDest[nDelegate] = Delegate.CreateDelegate(type,
delegates[nDelegate].Target, delegates[nDelegate].Method);
return Delegate.Combine(delegatesDest);
}
示例12: InvokeAsync
/// <summary>
/// Invokes every delegate method in new thread (except synchronized handlers).
/// </summary>
/// <param name="handler"></param>
/// <param name="parameters"></param>
public static void InvokeAsync(Delegate handler, params object[] parameters)
{
if (handler != null) {
foreach (Delegate d in handler.GetInvocationList()) {
ISynchronizeInvoke sync = d.Target as ISynchronizeInvoke;
if (sync != null) {
sync.BeginInvoke(d, parameters);
}
else {
ThreadPool.QueueUserWorkItem(new WaitCallback(AsyncInvokeProc), new AsyncInvokeArgs(d.Method, d.Target, parameters));
}
}
}
}
示例13: GetMethodList
public static MethodInfo[] GetMethodList(Delegate del)
{
if(del == null) {
throw new ArgumentNullException("del");
}
Delegate[] delegates = del.GetInvocationList();
MethodInfo[] methods = new MethodInfo[delegates.Length];
for(int i = 0; i < delegates.Length; i++) {
methods[i] = delegates[i].Method;
}
return methods;
}
示例14: RaiseEventOnUIThread
public static void RaiseEventOnUIThread(Delegate theEvent, object[] args)
{
foreach (Delegate d in theEvent.GetInvocationList())
{
ISynchronizeInvoke syncer = d.Target as ISynchronizeInvoke;
if (syncer == null)
{
d.DynamicInvoke(args);
}
else
{
syncer.BeginInvoke(d, args); // cleanup omitted
}
}
}
示例15: CallAsyncMethod
public static void CallAsyncMethod(Delegate eventDelegate, params object[] args)
{
if (eventDelegate != null)
{
Delegate[] delegates = eventDelegate.GetInvocationList();
AsyncInvokeDelegate invoker = new AsyncInvokeDelegate(InvokeDelegate);
AsyncCallback cleanUp = new AsyncCallback(AsyncDelegateCleanup);
foreach (Delegate sink in delegates)
{
invoker.BeginInvoke(sink, args, cleanUp, null);
}
}
}