Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / C#

How to run method in separate thread

4.93/5 (14 votes)
24 Mar 2011CPOL 38.3K  
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)