Click here to Skip to main content
15,881,757 members
Articles / Programming Languages / C#
Alternative
Tip/Trick

How to run method in separate thread

Rate me:
Please Sign up or sign in to vote.
4.93/5 (14 votes)
24 Mar 2011CPOL 37.2K   8   4
Or in the new framework 4.0 use parallel tasks?private void MethodStarter(){ Task myFirstTask = Task.Factory.StartNew(Method1); Task mySecondTask = Task.Factory.StartNew(Method1);}private void Method1(){}private void Method2(){}Sascha Barber wrote this[^]...
Or in the new framework 4.0 use parallel tasks?
C#
private void MethodStarter()
{
    Task myFirstTask = Task.Factory.StartNew(Method1);
    Task mySecondTask = Task.Factory.StartNew(Method1);
}

private void Method1()
{
}

private void Method2()
{
}


Sascha Barber wrote this[^] excellent article about Parallel Tasks.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect http://4dotnet.nl
Netherlands Netherlands
I'm developing software for over two decades. I'm working as a cloud solution architect and a team lead at 4DotNet in The Netherlands.

In my current position, I love to help customers with their journey to the cloud. I like to create highly performant software and to help team members to a higher level of software development.

My focus is on the Microsoft development stack, mainly C# and the Microsoft Azure Cloud. I also have a strong affinity with Angular. As a result of my contributions to the community, I received the Microsoft MVP Award for Microsoft Azure.

Comments and Discussions

 
QuestionHow-to-run-method-in-separate-thread and call back method Pin
Tridip Bhattacharjee19-Jul-12 20:49
professionalTridip Bhattacharjee19-Jul-12 20:49 
AnswerRe: How-to-run-method-in-separate-thread and call back method Pin
Eduard Keilholz23-Aug-12 0:47
Eduard Keilholz23-Aug-12 0:47 
GeneralReason for my vote of 4 prefered Pin
Benjamin Uboegbu5-Nov-11 0:16
professionalBenjamin Uboegbu5-Nov-11 0:16 
GeneralReason for my vote of 5 Agree! 5 Pin
Manfred Rudolf Bihy27-Mar-11 12:15
professionalManfred Rudolf Bihy27-Mar-11 12:15 

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.