Click here to Skip to main content
15,900,907 members
Home / Discussions / C#
   

C#

 
GeneralRe: C#: When one should go for factory method pattern instead of factory pattern Pin
OriginalGriff5-Apr-17 6:00
mveOriginalGriff5-Apr-17 6:00 
GeneralRe: C#: When one should go for factory method pattern instead of factory pattern Pin
Pete O'Hanlon5-Apr-17 7:33
mvePete O'Hanlon5-Apr-17 7:33 
GeneralRe: C#: When one should go for factory method pattern instead of factory pattern Pin
Luc Pattyn5-Apr-17 8:18
sitebuilderLuc Pattyn5-Apr-17 8:18 
GeneralRe: C#: When one should go for factory method pattern instead of factory pattern Pin
Pete O'Hanlon5-Apr-17 8:33
mvePete O'Hanlon5-Apr-17 8:33 
GeneralRe: C#: When one should go for factory method pattern instead of factory pattern Pin
OriginalGriff5-Apr-17 8:37
mveOriginalGriff5-Apr-17 8:37 
GeneralRe: C#: When one should go for factory method pattern instead of factory pattern Pin
Luc Pattyn5-Apr-17 9:02
sitebuilderLuc Pattyn5-Apr-17 9:02 
AnswerRe: C#: When one should go for factory method pattern instead of factory pattern Pin
Eddy Vluggen6-Apr-17 1:48
professionalEddy Vluggen6-Apr-17 1:48 
QuestionFactory pattern: issue with this definition "let subclass decide which class to instantiate." Pin
Tridip Bhattacharjee5-Apr-17 2:09
professionalTridip Bhattacharjee5-Apr-17 2:09 
AnswerRe: Factory pattern: issue with this definition "let subclass decide which class to instantiate." Pin
Pete O'Hanlon5-Apr-17 2:34
mvePete O'Hanlon5-Apr-17 2:34 
AnswerRe: Factory pattern: issue with this definition "let subclass decide which class to instantiate." Pin
Eddy Vluggen5-Apr-17 2:54
professionalEddy Vluggen5-Apr-17 2:54 
QuestionTask.Wait() -Why?? Pin
Kevin Marois4-Apr-17 6:54
professionalKevin Marois4-Apr-17 6:54 
AnswerRe: Task.Wait() -Why?? Pin
Pete O'Hanlon4-Apr-17 7:00
mvePete O'Hanlon4-Apr-17 7:00 
GeneralRe: Task.Wait() -Why?? Pin
Kevin Marois4-Apr-17 7:19
professionalKevin Marois4-Apr-17 7:19 
GeneralRe: Task.Wait() -Why?? Pin
Pete O'Hanlon4-Apr-17 7:26
mvePete O'Hanlon4-Apr-17 7:26 
GeneralRe: Task.Wait() -Why?? Pin
Richard Deeming4-Apr-17 7:38
mveRichard Deeming4-Apr-17 7:38 
GeneralRe: Task.Wait() -Why?? Pin
Pete O'Hanlon4-Apr-17 7:40
mvePete O'Hanlon4-Apr-17 7:40 
AnswerRe: Task.Wait() -Why?? Pin
Richard Deeming4-Apr-17 7:48
mveRichard Deeming4-Apr-17 7:48 
There are very few situations where it's necessary to block the current thread until a task has completed. The only obvious one that comes to mind is when you're writing a console application, and you want to use async code. And with .NET 4.5 or higher, it's usually better to call task.GetAwaiter().GetResult() rather than task.Wait(), to avoid having any exceptions wrapped in an AggregateException.
C#
static class Program
{
    static void Main()
    {
        MainAsync().GetAwaiter().GetResult();
    }
    
    static async Task MainAsync()
    {
        ...
    }
}

But in most cases, there's usually a better option than blocking the current thread.



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


GeneralRe: Task.Wait() -Why?? Pin
Kevin Marois4-Apr-17 7:52
professionalKevin Marois4-Apr-17 7:52 
GeneralRe: Task.Wait() -Why?? Pin
Richard Deeming4-Apr-17 8:04
mveRichard Deeming4-Apr-17 8:04 
GeneralRe: Task.Wait() -Why?? Pin
Tridip Bhattacharjee5-Apr-17 23:30
professionalTridip Bhattacharjee5-Apr-17 23:30 
GeneralRe: Task.Wait() -Why?? Pin
Richard Deeming6-Apr-17 1:30
mveRichard Deeming6-Apr-17 1:30 
Questionin which scenario people use factory design patter Pin
Tridip Bhattacharjee4-Apr-17 1:58
professionalTridip Bhattacharjee4-Apr-17 1:58 
AnswerRe: in which scenario people use factory design patter Pin
Eddy Vluggen4-Apr-17 2:29
professionalEddy Vluggen4-Apr-17 2:29 
GeneralRe: in which scenario people use factory design patter Pin
Tridip Bhattacharjee4-Apr-17 3:48
professionalTridip Bhattacharjee4-Apr-17 3:48 
GeneralRe: in which scenario people use factory design patter Pin
Pete O'Hanlon4-Apr-17 4:14
mvePete O'Hanlon4-Apr-17 4:14 

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.