Home > Net >  A Task cannot be called at the same time, how will need to complete the job queue to perform it?
A Task cannot be called at the same time, how will need to complete the job queue to perform it?

Time:05-05

 
the class one question{
Task to send;//the same time can only be called a
Public async void command to send command (string)
{
Mission sent=ClientWebSocket. SendAsync (new ArraySegment (Encoding UTF8. GetBytes (command), WebSocketMessageType. Text, true, the new CancellationToken ());
Await the task to send;
}
}
send because of Task can not be more than one thread calls at the same time, so, I want to write a can be multithreaded call the method at the same time, to deal with concurrency, excuse me this how to deal with, change the concurrent to handle the tasks one by one?

CodePudding user response:

Didn't understand what are you doing

The Parallel. Invoke (()=& gt; Task1 (), ()=& gt; Task2 (), ()=& gt; Task3 ());
  •  Tags:  
  • C#
  • Related