Click here to Skip to main content
15,880,796 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
AnswerRe: csv file sort and create a new and store the data Pin
Richard Deeming21-Sep-22 21:31
mveRichard Deeming21-Sep-22 21:31 
QuestionPLINQ - WithDegreeOfParallelism Pin
dataminers9-Sep-22 5:27
dataminers9-Sep-22 5:27 
AnswerRe: PLINQ - WithDegreeOfParallelism Pin
Richard MacCutchan9-Sep-22 5:50
mveRichard MacCutchan9-Sep-22 5:50 
GeneralRe: PLINQ - WithDegreeOfParallelism Pin
dataminers9-Sep-22 10:18
dataminers9-Sep-22 10:18 
GeneralRe: PLINQ - WithDegreeOfParallelism Pin
Richard MacCutchan9-Sep-22 21:53
mveRichard MacCutchan9-Sep-22 21:53 
GeneralRe: PLINQ - WithDegreeOfParallelism Pin
dataminers11-Sep-22 2:01
dataminers11-Sep-22 2:01 
GeneralRe: PLINQ - WithDegreeOfParallelism Pin
Dave Kreskowiak11-Sep-22 4:36
mveDave Kreskowiak11-Sep-22 4:36 
GeneralRe: PLINQ - WithDegreeOfParallelism Pin
Richard Deeming11-Sep-22 21:39
mveRichard Deeming11-Sep-22 21:39 
dataminers wrote:
the two code blocks below are the same
No they're not.

The first one starts a new task to execute CalculateSomething(5), and then suspends the current thread until that task completes. It then starts another task to execute CalculateSomething(8).

The second one starts two tasks to execute CalculateSomething(5) and CalculateSomething(8), and then freezes the current thread until both have completed.

If you time both approaches, the AsParallel code will be roughly twice as fast as the two await Task.Run(...) calls.

The closest equivalent using Task.Run would be:
C#
// Start both tasks in parallel:
Task t1 = Task.Run(() => CalculateSomething(5));
Task t2 = Task.Run(() => CalculateSomething(8));

// Wait for both tasks to complete:
await Task.WhenAll(t1, t2);
// Or: await t1; await t2;




"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer

QuestionMultiThread on Single Core Processor (CPU) Pin
dataminers6-Sep-22 3:24
dataminers6-Sep-22 3:24 
AnswerRe: MultiThread on Single Core Processor (CPU) Pin
dan!sh 6-Sep-22 3:46
professional dan!sh 6-Sep-22 3:46 
GeneralRe: MultiThread on Single Core Processor (CPU) Pin
dataminers6-Sep-22 22:28
dataminers6-Sep-22 22:28 
AnswerRe: MultiThread on Single Core Processor (CPU) Pin
Eddy Vluggen6-Sep-22 4:20
professionalEddy Vluggen6-Sep-22 4:20 
AnswerRe: MultiThread on Single Core Processor (CPU) Pin
Dave Kreskowiak6-Sep-22 4:38
mveDave Kreskowiak6-Sep-22 4:38 
GeneralRe: MultiThread on Single Core Processor (CPU) Pin
Eddy Vluggen6-Sep-22 5:14
professionalEddy Vluggen6-Sep-22 5:14 
GeneralRe: MultiThread on Single Core Processor (CPU) Pin
Dave Kreskowiak6-Sep-22 5:18
mveDave Kreskowiak6-Sep-22 5:18 
GeneralRe: MultiThread on Single Core Processor (CPU) Pin
Eddy Vluggen6-Sep-22 5:19
professionalEddy Vluggen6-Sep-22 5:19 
AnswerRe: MultiThread on Single Core Processor (CPU) Pin
Sam Hobbs5-Oct-22 20:19
Sam Hobbs5-Oct-22 20:19 
Question_ViewImports.cshtml question Pin
pkfox23-Aug-22 22:15
professionalpkfox23-Aug-22 22:15 
AnswerRe: _ViewImports.cshtml question Pin
Richard Deeming23-Aug-22 22:47
mveRichard Deeming23-Aug-22 22:47 
GeneralRe: _ViewImports.cshtml question Pin
pkfox23-Aug-22 23:13
professionalpkfox23-Aug-22 23:13 
GeneralRe: _ViewImports.cshtml question Pin
Richard Deeming23-Aug-22 23:29
mveRichard Deeming23-Aug-22 23:29 
GeneralRe: _ViewImports.cshtml question Pin
pkfox23-Aug-22 23:44
professionalpkfox23-Aug-22 23:44 
QuestionProblem with Azure AD JWT - solved Pin
pkfox18-Aug-22 5:56
professionalpkfox18-Aug-22 5:56 
QuestionRest API always return 401 status code Pin
Mou_kol10-Aug-22 0:59
Mou_kol10-Aug-22 0:59 
AnswerRe: Rest API always return 401 status code Pin
Gerry Schmitz10-Aug-22 4:05
mveGerry Schmitz10-Aug-22 4:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.