1
0
mirror of https://github.com/lidgren/lidgren-network-gen3.git synced 2026-05-06 02:11:06 +09:00

throw explanatory exception if trying to register callback with no sycnhronizationcontext

This commit is contained in:
lidgren
2011-07-18 21:08:08 +00:00
parent 0f66311460
commit 39459f6833
3 changed files with 6 additions and 6 deletions

View File

@@ -46,6 +46,8 @@ namespace Lidgren.Network
/// </summary>
public void RegisterReceivedCallback(SendOrPostCallback callback)
{
if (SynchronizationContext.Current == 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.Current, callback));