is it possible to run methods in parallel? pls see sample below for full details.
void main()
{
RunMethod1(); //runs for 5 seconds
RunMethod2(); //runs for 5 seconds
}
normally the program would end after 10 seconds.
but i want the program to complete in 7 seconds.
basically i want to do something like this.
Time in Sec 1 2 3 4 5 6 7 8 9 10
RunMethod1 1 2 3 4 5
RunMethod2 1 2 3 4 5
so the methods are running in parallel from (3rd to the 5th second)
is this possible? if so how?
Thanks!
AlanPosted Nov 17, 2008, 5:18 AM
It was announced at the PDC that the .NET Framework will be extended in Visual Studio 2010 to include support for parallel programming.
In the meantime, if you have a dual (or multi) core or processor machine, there is a CTP available of the Task Parallel Library (or TPL) and this article explains how to use it:
http://www.devx.com/dotnet/Article/39204/1763/page/1
However, as it's still early days for all this, I wouldn't (unless you're desperate) use it in a production application at the present time.
IamStalkerPosted Nov 17, 2008, 2:27 AM
You can put timer and trigger the event after 3 seconds and than let the the event do the stuff exactly 5 sec or what
ever.
Regards IamStalker!