public bool BeginGameAction(Action action, GameActionCallback callback, Object state) { try { ThreadPool.QueueUserWorkItem(o => { AutoResetEvent e = new AutoResetEvent(false); MySandboxGame.Static.Invoke(() => { if (m_gameThread == null) { m_gameThread = Thread.CurrentThread; } action( ); e.Set( ); }); e.WaitOne( ); if (callback != null) { callback(state); } }); return(true); } catch (Exception ex) { ApplicationLog.BaseLog.Error(ex); return(false); } }
public bool BeginGameAction(Action action, GameActionCallback callback, Object state) { try { ThreadPool.QueueUserWorkItem(new WaitCallback(delegate(Object arg) { AutoResetEvent e = new AutoResetEvent(false); SandboxGameAssemblyWrapper.Instance.EnqueueMainGameAction(new Action(delegate() { if (m_gameThread == null) { m_gameThread = Thread.CurrentThread; } action(); e.Set(); })); e.WaitOne(); if (callback != null) { callback(state); } })); return(true); } catch (Exception ex) { LogManager.ErrorLog.WriteLine(ex); return(false); } }
public bool BeginGameAction(Action action, GameActionCallback callback, Object state) { try { ThreadPool.QueueUserWorkItem(o => { AutoResetEvent e = new AutoResetEvent(false); /* * MyAPIGateway.Utilities.InvokeOnGameThread(() => * { * if (m_gameThread == null) * { * m_gameThread = Thread.CurrentThread; * } * * action(); * e.Set(); * }); */ Instance.EnqueueMainGameAction(() => { if (m_gameThread == null) { m_gameThread = Thread.CurrentThread; } action( ); e.Set( ); }); e.WaitOne( ); if (callback != null) { callback(state); } }); return(true); } catch (Exception ex) { ApplicationLog.BaseLog.Error(ex); return(false); } }
public bool BeginGameAction(Action action, GameActionCallback callback, Object state) { if (m_gameThread == Thread.CurrentThread) { throw new ThreadStateException("Invoking action on game thread from inside game thread! This will freeze the server!"); } try { ThreadPool.QueueUserWorkItem(o => { AutoResetEvent e = new AutoResetEvent(false); MySandboxGame.Static.Invoke(() => { if (m_gameThread == null) { m_gameThread = Thread.CurrentThread; } action( ); e.Set( ); }); e.WaitOne( ); if (callback != null) { callback(state); } }); return(true); } catch (Exception ex) { ApplicationLog.BaseLog.Error(ex); return(false); } }
public bool BeginGameAction( Action action, GameActionCallback callback, Object state ) { if (m_gameThread == Thread.CurrentThread) throw new ThreadStateException("Invoking action on game thread from inside game thread! This will freeze the server!"); try { ThreadPool.QueueUserWorkItem( o => { AutoResetEvent e = new AutoResetEvent( false ); MySandboxGame.Static.Invoke( ( ) => { if ( m_gameThread == null ) { m_gameThread = Thread.CurrentThread; } action( ); e.Set( ); } ); e.WaitOne( ); if ( callback != null ) { callback( state ); } } ); return true; } catch ( Exception ex ) { ApplicationLog.BaseLog.Error( ex ); return false; } }
public bool BeginGameAction( Action action, GameActionCallback callback, Object state ) { try { ThreadPool.QueueUserWorkItem( o => { AutoResetEvent e = new AutoResetEvent( false ); /* MyAPIGateway.Utilities.InvokeOnGameThread(() => { if (m_gameThread == null) { m_gameThread = Thread.CurrentThread; } action(); e.Set(); }); */ Instance.EnqueueMainGameAction(() => { if ( m_gameThread == null ) { m_gameThread = Thread.CurrentThread; } action( ); e.Set( ); } ); e.WaitOne( ); if ( callback != null ) { callback( state ); } } ); return true; } catch ( Exception ex ) { LogManager.ErrorLog.WriteLine( ex ); return false; } }
public bool BeginGameAction( Action action, GameActionCallback callback, Object state ) { try { ThreadPool.QueueUserWorkItem( o => { AutoResetEvent e = new AutoResetEvent( false ); MySandboxGame.Static.Invoke( ( ) => { if ( m_gameThread == null ) { m_gameThread = Thread.CurrentThread; } action( ); e.Set( ); } ); e.WaitOne( ); if ( callback != null ) { callback( state ); } } ); return true; } catch ( Exception ex ) { ApplicationLog.BaseLog.Error( ex ); return false; } }