Converted FireAndForget methods to use a singleton pattern to attempt to work around a Mono bug with nested delegates

prioritization
John Hurliman 2009-10-16 14:34:42 -07:00
parent 31dfe87570
commit 80a8a9c4a7
1 changed files with 21 additions and 2 deletions

View File

@ -44,6 +44,7 @@ using System.Xml;
using log4net;
using Nini.Config;
using Nwc.XmlRpc;
using BclExtras;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
@ -1269,15 +1270,33 @@ namespace OpenSim.Framework
#region FireAndForget Threading Pattern
public static void FireAndForget(System.Threading.WaitCallback callback)
/// <summary>
/// Created to work around a limitation in Mono with nested delegates
/// </summary>
private class FireAndForgetWrapper
{
public void FireAndForget(System.Threading.WaitCallback callback)
{
callback.BeginInvoke(null, EndFireAndForget, callback);
}
public static void FireAndForget(System.Threading.WaitCallback callback, object obj)
public void FireAndForget(System.Threading.WaitCallback callback, object obj)
{
callback.BeginInvoke(obj, EndFireAndForget, callback);
}
}
public static void FireAndForget(System.Threading.WaitCallback callback)
{
FireAndForgetWrapper wrapper = Singleton.GetInstance<FireAndForgetWrapper>();
wrapper.FireAndForget(callback);
}
public static void FireAndForget(System.Threading.WaitCallback callback, object obj)
{
FireAndForgetWrapper wrapper = Singleton.GetInstance<FireAndForgetWrapper>();
wrapper.FireAndForget(callback, obj);
}
private static void EndFireAndForget(IAsyncResult ar)
{