Quantcast
Channel: sshnet Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 1026

Commented Issue: Consider killing off the TaskFactory [1552]

$
0
0
We are moving to NServiceBus for some of our parts of the software, and suddenly the library stopped working (connection timeouts). So after a few hours of double checking everything, I decided to download the source and try it myself.

I found that the Connect method spawns a new listener thread (ExecuteThread). In this thread (NET40), the TaskFactory is used. However, when ran in my NServiceBus node the thread nevers gets spawned though the max number of threads is not just 1.

I have changed the ExecuteThread from:

Task.Factory.StartNew(action, TaskCreationOptions.LongRunning);

To

ThreadPool.QueueUserWorkItem((o) => { action(); });

And now it works great again.

Now to prevent any discussion whether this is or not is a bug in NServiceBus, it seems that the TaskFactory is not able to spawn the thread where the ThreadPool is able to. I actually don't see any reason to use the TaskFactory here.
Comments: ** Comment from web user: olegkap **

Hey,

Thanks for this info.
I originally used TaskFactory since my understanding was that in .4.0 we should use it but I guess they still have bugs, and you right there is no difference between method to another one.

I just commited 24900 changeset so you take a look at it.

Thanks,
Oleg


Viewing all articles
Browse latest Browse all 1026

Trending Articles