Home > Net > Ref asynchronous thread parameters are used to
Ref asynchronous thread parameters are used to
Time:09-28
Before the new limited understanding to some concepts, wrote a test were used in the production, to optimize the original program, step by step to make logical architecture more clearly, now rewrite a method using the ref parameters, found that if there is asynchronous thread will prompt wrong, can you tell me how to avoid? Thread synchronization speed too slow, temporary not consider
Thank you,
Private void test (ref int test)
{ . Task. Run (()=& gt; { If (test & lt; 1) { Sect_disp (0); .
CodePudding user response:
In asynchronous, anonymous methods (functions), lambda expressions such as scene is not allowed to use the ref or out parameters out, you need to modify the code to avoid this to happen, or do not use the ref or out, or do not use asynchronous,
CodePudding user response:
Doesn't support, and I don't want to out,
CodePudding user response:
So why do you ref?
People also need to know the ref outside? If want to know his outside, can task , can entrust to return, can IProcess notice
CodePudding user response:
I probably understand what you mean,
You don't use Task. Run For the Task. Factory. StartNew (Action, object) the overloading methodHand in the parameters,
If you need to return values To the Task. Factory. StartNew ((x)=& gt; {return (int) x + 1; }, object)