Click here to Skip to main content
15,559,732 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 22:31
mveRichard Deeming21-Sep-22 22:31 
QuestionPLINQ - WithDegreeOfParallelism Pin
dataminers9-Sep-22 6:27
dataminers9-Sep-22 6:27 
AnswerRe: PLINQ - WithDegreeOfParallelism Pin
Richard MacCutchan9-Sep-22 6:50
mveRichard MacCutchan9-Sep-22 6:50 
GeneralRe: PLINQ - WithDegreeOfParallelism Pin
dataminers9-Sep-22 11:18
dataminers9-Sep-22 11:18 
GeneralRe: PLINQ - WithDegreeOfParallelism Pin
Richard MacCutchan9-Sep-22 22:53
mveRichard MacCutchan9-Sep-22 22:53 
GeneralRe: PLINQ - WithDegreeOfParallelism Pin
dataminers11-Sep-22 3:01
dataminers11-Sep-22 3:01 
GeneralRe: PLINQ - WithDegreeOfParallelism Pin
Dave Kreskowiak11-Sep-22 5:36
mveDave Kreskowiak11-Sep-22 5:36 
GeneralRe: PLINQ - WithDegreeOfParallelism Pin
Richard Deeming11-Sep-22 22:39
mveRichard Deeming11-Sep-22 22: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 4:24
dataminers6-Sep-22 4:24 
AnswerRe: MultiThread on Single Core Processor (CPU) Pin
dan!sh 6-Sep-22 4:46
professional dan!sh 6-Sep-22 4:46 
GeneralRe: MultiThread on Single Core Processor (CPU) Pin
dataminers6-Sep-22 23:28
dataminers6-Sep-22 23:28 
AnswerRe: MultiThread on Single Core Processor (CPU) Pin
Eddy Vluggen6-Sep-22 5:20
professionalEddy Vluggen6-Sep-22 5:20 
AnswerRe: MultiThread on Single Core Processor (CPU) Pin
Dave Kreskowiak6-Sep-22 5:38
mveDave Kreskowiak6-Sep-22 5:38 
GeneralRe: MultiThread on Single Core Processor (CPU) Pin
Eddy Vluggen6-Sep-22 6:14
professionalEddy Vluggen6-Sep-22 6:14 
GeneralRe: MultiThread on Single Core Processor (CPU) Pin
Dave Kreskowiak6-Sep-22 6:18
mveDave Kreskowiak6-Sep-22 6:18 
GeneralRe: MultiThread on Single Core Processor (CPU) Pin
Eddy Vluggen6-Sep-22 6:19
professionalEddy Vluggen6-Sep-22 6:19 
AnswerRe: MultiThread on Single Core Processor (CPU) Pin
Sam Hobbs5-Oct-22 21:19
Sam Hobbs5-Oct-22 21:19 
Question_ViewImports.cshtml question Pin
pkfox23-Aug-22 23:15
professionalpkfox23-Aug-22 23:15 
AnswerRe: _ViewImports.cshtml question Pin
Richard Deeming23-Aug-22 23:47
mveRichard Deeming23-Aug-22 23:47 
GeneralRe: _ViewImports.cshtml question Pin
pkfox24-Aug-22 0:13
professionalpkfox24-Aug-22 0:13 
GeneralRe: _ViewImports.cshtml question Pin
Richard Deeming24-Aug-22 0:29
mveRichard Deeming24-Aug-22 0:29 
GeneralRe: _ViewImports.cshtml question Pin
pkfox24-Aug-22 0:44
professionalpkfox24-Aug-22 0:44 
QuestionProblem with Azure AD JWT - solved Pin
pkfox18-Aug-22 6:56
professionalpkfox18-Aug-22 6:56 
QuestionRest API always return 401 status code Pin
Mou_kol10-Aug-22 1:59
Mou_kol10-Aug-22 1:59 
AnswerRe: Rest API always return 401 status code Pin
Gerry Schmitz10-Aug-22 5:05
mveGerry Schmitz10-Aug-22 5: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.