Click here to Skip to main content
15,881,281 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to get Millions of files from folder and bulk insert in database Pin
Gerry Schmitz16-Oct-21 11:04
mveGerry Schmitz16-Oct-21 11:04 
AnswerRe: How to get Millions of files from folder and bulk insert in database Pin
OriginalGriff16-Oct-21 6:43
mveOriginalGriff16-Oct-21 6:43 
AnswerRe: How to get Millions of files from folder and bulk insert in database Pin
Michael Sydney Balloni16-Oct-21 17:36
professionalMichael Sydney Balloni16-Oct-21 17:36 
AnswerRe: How to get Millions of files from folder and bulk insert in database Pin
jschell24-Oct-21 6:50
jschell24-Oct-21 6:50 
QuestionPredicateBuilder Question Pin
Kevin Marois15-Oct-21 5:24
professionalKevin Marois15-Oct-21 5:24 
AnswerRe: PredicateBuilder Question Pin
Eddy Vluggen15-Oct-21 14:44
professionalEddy Vluggen15-Oct-21 14:44 
QuestionTask.WhenAll ConfigureAwait Question Pin
Kevin Marois14-Oct-21 12:57
professionalKevin Marois14-Oct-21 12:57 
AnswerRe: Task.WhenAll ConfigureAwait Question Pin
Richard Deeming14-Oct-21 23:15
mveRichard Deeming14-Oct-21 23:15 
ConfigureAwait(false) tells the code that you don't want to us the same "execution context" to continue running the method after the task has completed.

In a desktop application, when you start a task from the UI/dispatcher thread, running the method on the same execution context means running it on the UI thread. If you add .ConfigureAwait(false), the rest of the method will not run on the UI thread unless the task completes synchronously.

Since you want to run the rest of the method on the UI thread, you need to drop the .ConfigureAwait(false) from your code.

I'd also be inclined to drop the closures. And you don't really need Task.WhenAll here at all.
C#
Task<List<ProjectHeaderEntity>> projectsTask = Task.Run(() => AppCore.BizObject.GetProjectHeaders(AppCore.AppCompany.Id).ToList());
Task<List<NavigationGroupEntity>> jobsTask = Task.Run(() => AppCore.BizObject.GetJobListHeaders(AppCore.AppCompany.Id).ToList());

// At this point, both tasks have started running.
// Since you know the number of tasks, you don't need Task.WhenAll; just await both tasks.

List<ProjectHeaderEntity> projects = await projectsTask;
List<NavigationGroupEntity> jobs = await jobsTask;

var dialogVm = new VendorsByProjectAndJobReportViewModel(projects, jobs);
DialogResultEx result = DialogService.ShowDialog(dialogVm, typeof(MainWindowView));




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

GeneralRe: Task.WhenAll ConfigureAwait Question Pin
Kevin Marois15-Oct-21 4:53
professionalKevin Marois15-Oct-21 4:53 
GeneralRe: Task.WhenAll ConfigureAwait Question Pin
Richard Deeming15-Oct-21 5:59
mveRichard Deeming15-Oct-21 5:59 
GeneralRe: Task.WhenAll ConfigureAwait Question Pin
Kevin Marois15-Oct-21 6:29
professionalKevin Marois15-Oct-21 6:29 
GeneralRe: Task.WhenAll ConfigureAwait Question Pin
Kevin Marois15-Oct-21 8:08
professionalKevin Marois15-Oct-21 8:08 
GeneralRe: Task.WhenAll ConfigureAwait Question Pin
Richard Deeming17-Oct-21 21:58
mveRichard Deeming17-Oct-21 21:58 
GeneralRe: Task.WhenAll ConfigureAwait Question Pin
Kevin Marois18-Oct-21 4:01
professionalKevin Marois18-Oct-21 4:01 
QuestionCodility fails to compile even though it compiles in VS code? Pin
Cliff ludo13-Oct-21 6:41
Cliff ludo13-Oct-21 6:41 
AnswerRe: Codility fails to compile even though it compiles in VS code? Pin
BillWoodruff13-Oct-21 17:11
professionalBillWoodruff13-Oct-21 17:11 
Generalpass array to function Pin
Cliff ludo12-Oct-21 23:04
Cliff ludo12-Oct-21 23:04 
GeneralRe: pass array to function Pin
Richard Deeming12-Oct-21 23:25
mveRichard Deeming12-Oct-21 23:25 
GeneralRe: pass array to function Pin
Cliff ludo12-Oct-21 23:32
Cliff ludo12-Oct-21 23:32 
QuestionCreating An Async Method Pin
Kevin Marois7-Oct-21 11:02
professionalKevin Marois7-Oct-21 11:02 
AnswerRe: Creating An Async Method Pin
Richard Deeming7-Oct-21 21:41
mveRichard Deeming7-Oct-21 21:41 
GeneralRe: Creating An Async Method Pin
Kevin Marois8-Oct-21 6:00
professionalKevin Marois8-Oct-21 6:00 
GeneralRe: Creating An Async Method Pin
Richard Deeming8-Oct-21 6:35
mveRichard Deeming8-Oct-21 6:35 
GeneralRe: Creating An Async Method Pin
Kevin Marois8-Oct-21 6:38
professionalKevin Marois8-Oct-21 6:38 
GeneralRe: Creating An Async Method Pin
Kevin Marois8-Oct-21 9:46
professionalKevin Marois8-Oct-21 9:46 

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.