Where are the CLR-specific methods such as [delegate] .BeginInvoke documented?

[EDIT, To rephrase:] It looks like my question was poorly worded and poorly received. So I hope this complete rephrase helps ...

The MSDN clearly states: Control.BeginInvoke () Executes the delegate in the stream over which the control handle was created, usually it will be a GUI stream. And Dispatcher.BeginInvoke () will be launched in the thread where the Dispatcher object was created. This will be any thread created by me.

But for delegates, "the CLR automatically detects BeginInvoke and EndInvoke", and these calls are made instead of the ThreadPool thread. Other than this slightly surprisingly different behavior, I wonder how I can find the specifications of all the functions that are automatically implemented.

For example: Intelli-sense shows that my delegate has DynamicInvoke (). The System.Delegate {} class has DynamicInvoke (), which may mean that my delegate inherits it. But the delegate {} does not have BeginInvoke (). And the delegate {} has several functions that my delegate does not have. Also my delegate gets the GetObjectData () method. And it seems to come from ISerializable.

So, in conclusion, the delegate appears, gets its methods from (1) the CLR "automatically", (2) a certain subset of the delegation {} is possibly MulticastDelegate {} and, possibly, (3) ISerializble. Where can I find the full specification of all the methods that the delegate gets? BeginInvoke () is especially interesting, and it is an exact signature , since the two above-mentioned methods with this name have different sets of signatures.

[Someone suggested in editing that the "delegate" is a "delegate". I suppose this is not so.]

thank

+6
source share
2 answers

Control.Begin/End/Invoke() Dispatcher.Begin/End/Invoke() Begin/End/Invoke(), . , , Control Dispatcher. Runtime .

, , CLI, ECMA 335, II.14.6. , .

, MulticastDelegate ( , CLI). 4 , CLR:

  • , IntPtr. - Delegate.Target, IntPtr - Delegate.Method. , , Target , , , , null . Method , . , + =. .

  • Invoke(). . Invoke() , . #, , -, , .

  • BeginInvoke() . , , ThreadPool.QueueUserWorkItem, , . - System.IAsyncResult, , EndInvoke(). - System.AsyncCallback, , . - , , . .

  • EndInvoke(). IAsyncResult, , BeginInvoke(). .

, , - , , MulticastDelegate Delegate. DynamicInvoke() GetObjectData().

, . .NETCore, Silverlight. , Threadpool.QueueUserWorkItem(). , , , . EndInvoke(), 10 . , EndInvoke(). , . Task Thread .

MSDN , . , , .

+21

. MSDN , , :)

, . MSDN. http://msdn.microsoft.com/en-us/magazine/cc164139.aspx , ( , ) BeginInvoke EndInvoke .NET CLR. , , . CLR Via #.

. , .

.Invoke Winforms. . WPF Control.Invoke. WPF Control.

. .

, .

, MSDN, . ( msdn http://msdn.microsoft.com/en-us/library/ms173171(v=vs.80).aspx)

public delegate int PerformCalculation(int x, int y);

, ( "d" ). . PerformCalculation, .

, , .

, , :

using System;
// Declare delegate -- defines required signature:
delegate void SampleDelegate(string message);

class TestDelegate
{
    private void CallMeUsingDelegate(string m_param)
    {
        Console.WriteLine("Called me using parameter - " + m_param);
    }

    public static void Main(string[] args)
    {
        // Here is the Code that uses the delegate defined above.
        SampleDelegate sd = new SampleDelegate(CallMeUsingDelegate);
        sd.Invoke("FromMain");
    }
}

CallMeUsingDelegate . # , .

,

System;   // - :    void SampleDelegate ( );

class TestDelegate
{
    public static void Main(string[] args)
    {
        // Here is the Code that uses the delegate defined above.
        SampleDelegate sd = delegate(param) {
                        Console.WriteLine("Called me using parameter - " + param);
                    };

        sd.Invoke("FromMain");
    }
}

, . . IL . 2 .

BeginInvoke EndInvoke, . threadpool, CLR.

, , ,

IAsyncResult ar = sd.BeginInvoke(CallMeUsingDelegate, callMeOnCompletion, sd);

Delegate - , . , , Thread BeginInvoke, , Delegate, ThreadPool CLR. , IAsyncResult. , ( , sd 3).

CallMeUsingDelegate (ThreadPool). , ThreadPool , 2 .

, , EndInvoke, ???

, , EndInvoke, CLR ThreadPool , . EndInvoke .

, ( ), .

+8

All Articles