Click here to Skip to main content
11,802,762 members (74,405 online)
Click here to Skip to main content

Tagged as

How to run method in separate thread

, 24 Mar 2011 CPOL 16.7K 8
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[^]...


Members may post updates or alternatives to this current article in order to show different approaches or add new features.

24 Mar 2011
J a a n s
Much easier to go for async MethodInvoker(MyMethod).BeginInvoke(null, null);We can use the suitable overload in case of parameters/callback methods.Note: MethodInvoker is available inside the System.Windows.Forms name space. You can create your own delegates also.
25 Mar 2011
Pavel Yermalovich
3 alternatives  
24 Mar 2011
Nick Reshetinsky
You may actualy skip delegate types when assigning a method to execute: private void DoLongOperation( ) { // long processing } Thread thr = new Thread(DoLongOperation); thr.Start( );


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


About the Author

Eduard Keilholz
Software Developer (Senior)
Netherlands Netherlands
In 1998 I started as webdesigner programming websites in Perl and later PHP. After two years wrote most of the websites in ASP and from then on lost the feeling with a linux/unix platform.

Since 2001 interested in Windows applications and now writing software using mostly C# for about 7 years now.

| | Privacy | Terms of Use | Mobile
Web02 | 2.8.151002.1 | Last Updated 25 Mar 2011
Article Copyright 2011 by Eduard Keilholz
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid