Run slow operations in a separate thread, instead of using FireAndForget (which has a 1-minute timeout)

Resolves http://opensimulator.org/mantis/view.php?id=6945
This commit is contained in:
Oren Hurvitz
2014-01-29 16:14:27 +02:00
parent 84d7227dfd
commit e131e73652
7 changed files with 35 additions and 12 deletions

View File

@@ -2319,6 +2319,29 @@ namespace OpenSim.Framework
#endregion FireAndForget Threading Pattern
/// <summary>
/// Run the callback on a different thread, outside the thread pool. This is used for tasks
/// that may take a long time.
/// </summary>
public static void RunThreadNoTimeout(WaitCallback callback, string name, object obj)
{
Thread t = new Thread(delegate()
{
try
{
Culture.SetCurrentCulture();
callback(obj);
}
catch (Exception e)
{
m_log.Error("Exception in thread " + name, e);
}
});
t.Name = name;
t.Start();
}
/// <summary>
/// Environment.TickCount is an int but it counts all 32 bits so it goes positive
/// and negative every 24.9 days. This trims down TickCount so it doesn't wrap