This isn't a bug. Your framework is a pleasure to use.
I've run into an issue where I'm initialising the NetClient on the UI thread,
but would like the callbacks to be executed in the ThreadPool, not the UI
thread.
I could make the code change myself, but I'd prefer to avoid local changes to
your code.
Would you mind adding the following function
overload?NetPeer.RegisterReceivedCallback(SendOrPostCallback callback,
SynchronizationContext synchronizationContext)
The implementation could look something like:
/// <summary>
/// Call this to register a callback for when a new message arrives
/// </summary>
public void RegisterReceivedCallback(SendOrPostCallback callback)
{
RegisterReceivedCallback(callback, SynchronizationContext.Current);
}
/// <summary>
/// Call this to register a callback for when a new message arrives
/// </summary>
public void RegisterReceivedCallback(SendOrPostCallback callback,
SynchronizationContext synchronizationContext)
{
if (synchronizationContext == null)
throw new NetException("Need a SynchronizationContext to register callback on correct thread!");
if (m_receiveCallbacks == null)
m_receiveCallbacks = new List<NetTuple<SynchronizationContext, SendOrPostCallback>>();
m_receiveCallbacks.Add(new NetTuple<SynchronizationContext, SendOrPostCallback>(synchronizationContext, callback));
}
Original issue reported on code.google.com by crowe.da...@gmail.com on 21 Jan 2014 at 2:05
Original issue reported on code.google.com by
crowe.da...@gmail.com
on 21 Jan 2014 at 2:05