Click here to Skip to main content
15,891,942 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
 
I need to know two things 
 
1.I would like to know which is best to use either Task.Run or TaskFactory.StartNew(), When to use this in async Programming, What are all the Main Difference?, Can you anyone Give me the list of valid points.
 
2. Can we use all method as Task in WPF, is there any dis-advantages available while am using all method as Task in WPF?
 
 
Thanks in Advance. 


What I have tried:

Searched About these all but i couldn't get proper explanation
Posted
Updated 25-Jul-17 7:28am

1 solution

1. Both methods do almost the same. Second one is recommended if you do not need to specify TaskCreationOptions or TaskContinuationOptions or TaskScheduler.
For more details you can read
StartNew is Dangerous[^]
and
c# - What is the difference between Task.Run() and Task.Factory.StartNew() - Stack Overflow[^]

2. I do not see any disadvantages in returning Task as a result in WPF.

If you need to interact with UI in your methods you have to use Dispatcher. Is it what you are asking?

If you share some examples of your code I can be more specific in my answer.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900