Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use of Task.Factory.StartNew in PublishOnBackgroundThread() method #18

Closed
zachjacobs opened this issue Mar 24, 2014 · 3 comments
Closed

Comments

@zachjacobs
Copy link

This is more of a question than anything. We have noticed occasions where our message handlers would be executing on the UI thread even though we always post messages using the PublishOnBackgroundThread method to publish these messages. Upon reading into the issue and looking at the Caliburn.Micro source, I suspect this might be due to the usage of Task.Factory.StartNew in the PublishOnBackgroundThread method. Would Task.Run be more appropriate here to ensure that we are always using TaskScheduler.Default?

http://richnewman.wordpress.com/2012/11/21/why-starting-a-new-task-in-the-task-parallel-library-tpl-doesnt-always-start-a-new-thread/

@tibel
Copy link
Contributor

tibel commented Mar 28, 2014

As we support Silverlight 5 and .NET 4.0 Task.Run is not an option.
If I remember correctly it is only a wrapper around Task.Factory.StartNew, so it should be enough to set the right parameters. Suggestions?

@tibel
Copy link
Contributor

tibel commented Apr 4, 2014

@tibel tibel closed this as completed in 3aa7bca Apr 4, 2014
@zachjacobs
Copy link
Author

My apologies on not following up with your question. I was on vacation last week. Your fix is exactly what I would have suggested. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants