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 log4net;
using Nini.Config; using Nini.Config;
using Nwc.XmlRpc; using Nwc.XmlRpc;
using BclExtras;
using OpenMetaverse; using OpenMetaverse;
using OpenMetaverse.StructuredData; using OpenMetaverse.StructuredData;
@ -1269,14 +1270,32 @@ namespace OpenSim.Framework
#region FireAndForget Threading Pattern #region FireAndForget Threading Pattern
/// <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 void FireAndForget(System.Threading.WaitCallback callback, object obj)
{
callback.BeginInvoke(obj, EndFireAndForget, callback);
}
}
public static void FireAndForget(System.Threading.WaitCallback callback) public static void FireAndForget(System.Threading.WaitCallback callback)
{ {
callback.BeginInvoke(null, EndFireAndForget, callback); FireAndForgetWrapper wrapper = Singleton.GetInstance<FireAndForgetWrapper>();
wrapper.FireAndForget(callback);
} }
public static void FireAndForget(System.Threading.WaitCallback callback, object obj) public static void FireAndForget(System.Threading.WaitCallback callback, object obj)
{ {
callback.BeginInvoke(obj, EndFireAndForget, callback); FireAndForgetWrapper wrapper = Singleton.GetInstance<FireAndForgetWrapper>();
wrapper.FireAndForget(callback, obj);
} }
private static void EndFireAndForget(IAsyncResult ar) private static void EndFireAndForget(IAsyncResult ar)