public override void Switch() { if (reset == null) { throw new ObjectDisposedException(null); } state = FiberState.Running; reset.Set(); CurrentFiber.WaitOrJoin(this); }
public override void Switch() { if (m_fiber == IntPtr.Zero) { throw new ObjectDisposedException(null); } state = FiberState.Running; CurrentFiber.state = FiberState.Suspended; Kernel32.SwitchToFiber(m_fiber); }
protected virtual void Dispose(bool disposing) { if (disposing) { state = FiberState.Terminated; reset = null; if (m_thread != null) { m_thread.IsBackground = true; m_thread.Abort(); m_thread = null; } } }
public void ChangeFiberState(long handle, string state) { FiberState fiberState; lock (_fiberLock) { if (!_fibers.TryGetValue(handle, out fiberState)) { fiberState = new FiberState(); _fibers.Add(handle, fiberState); } fiberState.State = state; } }
private void ThreadRoutine(ThreadStart start) { Wait(); if (m_thread == null) { return; } state = FiberState.Running; m_thread.IsBackground = false; start(); state = FiberState.Terminated; reset = null; done.Set(); m_thread = null; Dispose(); }
protected virtual void Dispose(bool disposing) { if (Handle != IntPtr.Zero) { var handle = GCHandle.FromIntPtr(Handle); handle.Free(); Handle = IntPtr.Zero; if (m_fiber != IntPtr.Zero) { Kernel32.DeleteFiber(m_fiber); m_fiber = IntPtr.Zero; } state = FiberState.Terminated; try{ ThreadFibers.Value.Remove(this); CleanupFibers(); }catch (ObjectDisposedException) { } } }