I recently created a prototype C # console application to read in parallel the four devices measurements (on the same
TimeStamp << class> / code>), I did the command of parallel.invoke Used, the results were quite good once every single time. Later I tried to apply the same concept in the backgroundworker by using Winforms so my in DuWorks I read this parallel.invoke I want to run four functions to get, but the results are returned after such a long time and they are not at the same time on the stamp, I tried to do it without the background, but I have only one result Is anyone Even know why parallel.invoke is behaving? Does it work fine in the console and not in winform? Is there a way to ensure that multiple async procces execution is running in parallel? I have a hard time understanding, please help me here. Update : Sorry for the confusion, I did this before the parallel invitation, later I changed it into the job but the behavior is the same. Console Application : Public Stable Zero Funny () (for (int i = 0; i {funcb ();}, () = & Gt; {funcc ();}, () => {Fun ();}, () => (Funcd ();}) Var factory = new functionality (functioning option. Langraning, Task Continuation option. Non;) Task T 1 = Factory. (Funky); Task T2 = Factory: Startup (Funkab); Task T3 = Factory: Start (Funky); Task T4 = Factory. Started (Faxed); t1.Wait (); t2 Wait (); t3.Wait (); t4.Wait (); WriteToFile () results written for the file} My in the goi app I am doing this in backgroundWorker I have the same reading task as defined above that I am in my GUI application. Am Yoga: public static void fun (() (Int i = 0; I & lt; 5; I ++) {rawData = fmio.IO. Read (4 * numReadings); Receiving data in // byte array RawData1.Add (rawData); // put it in ArrayList}} public static zero funcb () {for (int i = 0; i <5; i ++) {rawData2 = fmio.IO.Read (4 * numReadings); RawData2.Add (rawData2); }} Private Zero btn_StartMeasurement_Click (Object Sender, EventArgs e) {if (! BwObj.IsBusy) {bw_Obj.RunWorkerAsync (); }} Private Zero bw_Obj_DoWork_1 (Object Sender, DoWorkEventArgs E) {//Parallel.Invoke ((=) gt; {funcb ();}, () => {funcc ();}, () => gt; ; {Ficca ();}, () = & gt; {funcd ();}); Var Factory A = New WorkForce (Functional Option. Langaran, Task Continuation Option.); Var Time = System.Diagnostics.Stopwatch.StartNew (); Task T1 = Factory A. StartNew (() = & gt; Funka (Globals.num readings, DMM)); Task T2 = Factory A. Start (=) gt; fax (globals.name readings, DMM2); Task T3 = Factory A. StartNew ((=) = Fenq (Globals. Name readings, DMM3); Task T4 = Factory A. StartNew (() => Moncad (Globals. Nom readings, DMM4); T1.Wait (); T2.Wait (); T3.Wait (); T4.Wait (); WriteToFile (); }
I handle the problem like this: to remove the parallel-reading code In your own stable category, then call the console application and both from the winforms application, and see what happens that you should get something from yourself that goes either way , Or does not work at all (because you're calling the same code).
Comments
Post a Comment