Click here to Skip to main content
16,016,157 members
Home / Discussions / C#
   

C#

 
GeneralRe: Page refresh Pin
Łukasz Nowakowski21-Oct-10 23:34
Łukasz Nowakowski21-Oct-10 23:34 
GeneralRe: Page refresh Pin
juman_achu21-Oct-10 23:40
juman_achu21-Oct-10 23:40 
GeneralRe: Page refresh [modified] Pin
thatraja21-Oct-10 23:58
professionalthatraja21-Oct-10 23:58 
QuestionI am confused with Delegates, Events and Threads Pin
rahul.kulshreshtha21-Oct-10 20:15
rahul.kulshreshtha21-Oct-10 20:15 
AnswerRe: I am confused with Delegates, Events and Threads [modified] Pin
Sivaraman Dhamodharan21-Oct-10 20:58
Sivaraman Dhamodharan21-Oct-10 20:58 
GeneralRe: I am confused with Delegates, Events and Threads Pin
rahul.kulshreshtha21-Oct-10 21:45
rahul.kulshreshtha21-Oct-10 21:45 
GeneralRe: I am confused with Delegates, Events and Threads Pin
Sivaraman Dhamodharan21-Oct-10 23:16
Sivaraman Dhamodharan21-Oct-10 23:16 
AnswerRe: I am confused with Delegates, Events and Threads PinPopular
DaveyM6921-Oct-10 21:29
professionalDaveyM6921-Oct-10 21:29 
Calling a delegate is basically the same as calling the method(s) in the delegate's invocation list directly.
However, if you call BeginInvoke on the delegate, a new thread will be created and the methods will be called on that.

A little demo to show:
C#
using System;
using System.Threading;

class Program
{
    static void Main(string[] args)
    {
        Console.WriteLine("Main Thread");
        Console.WriteLine(Thread.CurrentThread.ManagedThreadId);
        Test test = new Test();
        Console.WriteLine("Direct Method Call");
        test.Method();
        MethodDelegate methodDelegate = new MethodDelegate(test.Method);
        Console.WriteLine("Direct Delegate Call");
        methodDelegate();
        Console.WriteLine("Delegate Invoke");
        methodDelegate.Invoke();
        Console.WriteLine("Delegate BeginInvoke");
        methodDelegate.BeginInvoke(null, null);
        Console.ReadKey();
    }
}

public delegate void MethodDelegate();

class Test
{
    public void Method()
    {
        Console.WriteLine(Thread.CurrentThread.ManagedThreadId);
    }
}

Dave

Binging is like googling, it just feels dirtier.
Please take your VB.NET out of our nice case sensitive forum.
Astonish us. Be exceptional. (Pete O'Hanlon)

BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)



GeneralRe: I am confused with Delegates, Events and Threads Pin
rahul.kulshreshtha21-Oct-10 21:50
rahul.kulshreshtha21-Oct-10 21:50 
AnswerRe: I am confused with Delegates, Events and Threads Pin
Sauro Viti21-Oct-10 23:29
professionalSauro Viti21-Oct-10 23:29 
QuestionLogging on Removable Device Pin
wenlong8821-Oct-10 19:22
wenlong8821-Oct-10 19:22 
AnswerRe: Logging on Removable Device Pin
Dave Kreskowiak22-Oct-10 0:59
mveDave Kreskowiak22-Oct-10 0:59 
GeneralRe: Logging on Removable Device Pin
wenlong8822-Oct-10 2:05
wenlong8822-Oct-10 2:05 
GeneralRe: Logging on Removable Device Pin
Dave Kreskowiak22-Oct-10 13:26
mveDave Kreskowiak22-Oct-10 13:26 
GeneralRe: Logging on Removable Device Pin
wenlong8822-Oct-10 17:24
wenlong8822-Oct-10 17:24 
AnswerRe: Logging on Removable Device Pin
_Erik_22-Oct-10 4:20
_Erik_22-Oct-10 4:20 
GeneralRe: Logging on Removable Device Pin
Dave Kreskowiak22-Oct-10 13:27
mveDave Kreskowiak22-Oct-10 13:27 
GeneralRe: Logging on Removable Device Pin
_Erik_22-Oct-10 22:34
_Erik_22-Oct-10 22:34 
GeneralRe: Logging on Removable Device Pin
Dave Kreskowiak23-Oct-10 7:46
mveDave Kreskowiak23-Oct-10 7:46 
GeneralRe: Logging on Removable Device Pin
wenlong8822-Oct-10 17:22
wenlong8822-Oct-10 17:22 
QuestionReference a method from one user control from within another user control? Pin
Ian Durward21-Oct-10 15:17
Ian Durward21-Oct-10 15:17 
AnswerRe: Reference a method from one user control from within another user control? [modified] Pin
Karthik. A21-Oct-10 16:46
Karthik. A21-Oct-10 16:46 
AnswerRe: Reference a method from one user control from within another user control? Pin
Ravi Bhavnani21-Oct-10 17:19
professionalRavi Bhavnani21-Oct-10 17:19 
AnswerRe: Reference a method from one user control from within another user control? Pin
_Erik_22-Oct-10 4:50
_Erik_22-Oct-10 4:50 
GeneralRe: Reference a method from one user control from within another user control? Pin
Ian Durward22-Oct-10 8:18
Ian Durward22-Oct-10 8:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.