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

C#

 
AnswerRe: Upate Exe Build Number Pin
Richard Deeming14-Apr-20 0:05
mveRichard Deeming14-Apr-20 0:05 
Questiontraversing two lists simultaneously Pin
Pita329-Apr-20 9:11
Pita329-Apr-20 9:11 
AnswerRe: traversing two lists simultaneously Pin
OriginalGriff9-Apr-20 9:29
mveOriginalGriff9-Apr-20 9:29 
AnswerRe: traversing two lists simultaneously Pin
Dave Kreskowiak9-Apr-20 9:31
mveDave Kreskowiak9-Apr-20 9:31 
AnswerRe: traversing two lists simultaneously Pin
Gerry Schmitz9-Apr-20 10:57
mveGerry Schmitz9-Apr-20 10:57 
AnswerRe: traversing two lists simultaneously Pin
James Curran13-Apr-20 1:14
James Curran13-Apr-20 1:14 
Question2 Async/Await Questions Pin
Kevin Marois8-Apr-20 18:10
professionalKevin Marois8-Apr-20 18:10 
AnswerRe: 2 Async/Await Questions Pin
Richard Deeming9-Apr-20 0:16
mveRichard Deeming9-Apr-20 0:16 
If there's no return value, then it makes sense to return Task rather than Task<T>. I've never seen any problems doing that.

For the property setter, I'd be inclined to change it to:
C#
set
{
    if (_SelectedCompanyHeader != value)
    {
        _SelectedCompanyHeader = value;
        RaisePropertyChanged(nameof(SelectedCompanyHeader));
        _ = LoadProjects();
    }
}
following the advice from David Fowler:
AspNetCoreDiagnosticScenarios/AsyncGuidance.md at master · davidfowl/AspNetCoreDiagnosticScenarios · GitHub[^]

new Task(fn).Start() should generally be replaced with Task.Run(fn). But in this case, LoadProjects already returns a Task, so there's no need to create another one.

If the method fails, it will raise the TaskScheduler.UnobservedTaskException[^] event rather than terminating your process.

If you didn't assign the result to a discard, you'd get a IDE0058 warning.


NB: If possible, I'd also be inclined to update your RaisePropertyChanged method to use the CallerMemberName attribute, so that you wouldn't need to pass in the property name when you call the method from a property setter.
C#
protected void RaisePropertyChanged([CallerMemberName] string propertyName = default) { ... }

...

public CompanyHeaderEntity SelectedCompanyHeader
{
    get { return _SelectedCompanyHeader; }
    set
    {
        if (_SelectedCompanyHeader != value)
        {
            _SelectedCompanyHeader = value;
            RaisePropertyChanged(); // <- The current property name will automatically be passed here.
            _ = LoadProjects();
        }
    }
}
Caller Information (C#) | Microsoft Docs[^]

If for some reason you can't do that, at least use nameof instead of strings. That way, if you use a refactoring tool to rename the property, the value passed to the RaisePropertyChanged method will be updated to match.
nameof expression - C# reference | Microsoft Docs[^]



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

GeneralRe: 2 Async/Await Questions Pin
Kevin Marois9-Apr-20 6:22
professionalKevin Marois9-Apr-20 6:22 
QuestionGetting Text From External Application Pin
KiriGaya-Rye8-Apr-20 13:09
KiriGaya-Rye8-Apr-20 13:09 
QuestionHow to read/load a certificate stored in a JKS (Java key stores) file format, in .NET (C#) Pin
yuvraj vichare8-Apr-20 5:20
yuvraj vichare8-Apr-20 5:20 
AnswerRe: How to read/load a certificate stored in a JKS (Java key stores) file format, in .NET (C#) Pin
jkirkerx8-Apr-20 9:38
professionaljkirkerx8-Apr-20 9:38 
QuestionBackground Data Tables In C# Pin
Member 133258467-Apr-20 0:21
Member 133258467-Apr-20 0:21 
AnswerRe: Background Data Tables In C# Pin
Gerry Schmitz7-Apr-20 6:52
mveGerry Schmitz7-Apr-20 6:52 
AnswerRe: Background Data Tables In C# Pin
Mycroft Holmes7-Apr-20 11:11
professionalMycroft Holmes7-Apr-20 11:11 
AnswerRe: Background Data Tables In C# Pin
#realJSOP8-Apr-20 5:45
mve#realJSOP8-Apr-20 5:45 
GeneralRe: Background Data Tables In C# Pin
Mycroft Holmes8-Apr-20 13:15
professionalMycroft Holmes8-Apr-20 13:15 
GeneralRe: Background Data Tables In C# Pin
#realJSOP9-Apr-20 3:37
mve#realJSOP9-Apr-20 3:37 
QuestionNeed some tips... Sharing a collection of classes for display in a listbox? Pin
DaveHopeDev14-Apr-20 10:58
DaveHopeDev14-Apr-20 10:58 
AnswerRe: Need some tips... Sharing a collection of classes for display in a listbox? Pin
Luc Pattyn4-Apr-20 11:57
sitebuilderLuc Pattyn4-Apr-20 11:57 
GeneralRe: Need some tips... Sharing a collection of classes for display in a listbox? Pin
DaveHopeDev14-Apr-20 22:45
DaveHopeDev14-Apr-20 22:45 
GeneralRe: Need some tips... Sharing a collection of classes for display in a listbox? Pin
Luc Pattyn5-Apr-20 2:11
sitebuilderLuc Pattyn5-Apr-20 2:11 
GeneralRe: Need some tips... Sharing a collection of classes for display in a listbox? Pin
DaveHopeDev15-Apr-20 6:18
DaveHopeDev15-Apr-20 6:18 
GeneralRe: Need some tips... Sharing a collection of classes for display in a listbox? Pin
Luc Pattyn5-Apr-20 6:21
sitebuilderLuc Pattyn5-Apr-20 6:21 
AnswerRe: Need some tips... Sharing a collection of classes for display in a listbox? Pin
Mycroft Holmes4-Apr-20 12:41
professionalMycroft Holmes4-Apr-20 12:41 

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.