public ScriptUtilites(BindableList variables, Playfield playfield, HandleManager handleManager, OptionsPanel optionsPanel) { this.variables = variables; this.playfield = playfield; this.handleManager = handleManager; this.optionsPanel = optionsPanel; }
public void UpdateHandles() { var root = new HandleObject(); root.Children.Add(HandleManager.GetAllHandleObject()); this._root = root; }
protected CabBase() { this.streamHandles = new HandleManager(); this.erf = new ERF(); this.status = new CabinetStatus(); // 32K seems to be the size of the largest chunks processed by cabinet.dll. // But just in case, this buffer will auto-enlarge. this.buf = new byte[32768]; }
protected CabWorker(CabEngine cabEngine) { this.cabEngine = cabEngine; this.streamHandles = new HandleManager<Stream>(); this.erf = new NativeMethods.ERF(); this.erfHandle = GCHandle.Alloc(this.erf, GCHandleType.Pinned); this.cabNumbers = new Dictionary<string, short>(1); // 32K seems to be the size of the largest chunks processed by cabinet.dll. // But just in case, this buffer will auto-enlarge. this.buf = new byte[32768]; }
static void Main(string[] args) { MountManager.Init(); HandleManager.Init(); var nfs = new NfsHandler(); var mount = new MountHandler(); var portmap = new PortmapHandler(); nfs.Start(); mount.Start(); portmap.Start(); }
public static int SignalAndWait( IntPtr handleToSignal, IntPtr handleToWaitOn, int timeoutMilliseconds) { Debug.Assert(timeoutMilliseconds >= -1); return (SignalAndWait( HandleManager.FromHandle(handleToSignal), HandleManager.FromHandle(handleToWaitOn), timeoutMilliseconds)); }
public static bool Wait(IntPtr handle, int timeoutMilliseconds) { Debug.Assert(timeoutMilliseconds >= -1); ThreadWaitInfo waitInfo = RuntimeThread.CurrentThread.WaitInfo; if (waitInfo.CheckAndResetPendingInterrupt) { throw new ThreadInterruptedException(); } return(HandleManager.FromHandle(handle).Wait(waitInfo, timeoutMilliseconds)); }
public static void ResetEvent(IntPtr handle) { WaitableObject waitableObject = HandleManager.FromHandle(handle); s_lock.Acquire(); try { waitableObject.UnsignalEvent(); } finally { s_lock.Release(); } }
public static void ReleaseMutex(IntPtr handle) { WaitableObject waitableObject = HandleManager.FromHandle(handle); s_lock.Acquire(); try { waitableObject.SignalMutex(); } finally { s_lock.Release(); } }
public static int ReleaseSemaphore(IntPtr handle, int count) { Debug.Assert(count > 0); WaitableObject waitableObject = HandleManager.FromHandle(handle); s_lock.Acquire(); try { return(waitableObject.SignalSemaphore(count)); } finally { s_lock.Release(); } }
private void Client_Started(object sender, EventArgs e) { ClientManager.ClientReg.RegClient(this); for (var i = 0; i < 10; i++) { #if DEBUG System.Diagnostics.Debug.Print("Mutex Kill Attempt Nr" + i); #endif try { //if (HandleManager.ClearMutex(ClientManager.ClientInfo.ProcessName, "AN-Mutex-Window-Guild Wars 2", ref nomutexpros)) i = 10; if (HandleManager.KillHandle(this, "AN-Mutex-Window-Guild Wars 2", false)) { i = 10; } } catch (Exception err) { // Attempt to allow true broken states to fail. if (err is InvalidOperationException) { i = 10; } #if DEBUG // Attempt to allow race conditions in DEBUG mode. System.Diagnostics.Debug.Print(err.Message); #else // Tell the user what happened... Maybe? if (i == 10) { MessageBox.Show("Mutex release failed, will try again. Please provide the following if you want to help fix this problem: \r\n" + err.GetType().ToString() + "\r\n" + err.Message + "\r\n" + err.StackTrace); } #endif } //Maxtime 10 secs Thread.Sleep((int)(Math.Pow(i, 2) * 25 + 50)); } EnableRaisingEvents = true; Exited += Client_Exited; foreach (var plugin in PluginManager.PluginCollection) { plugin.Client_PostLaunch(); } }
private static SafeWaitHandle NewHandle(WaitableObject waitableObject) { IntPtr handle = HandleManager.NewHandle(waitableObject); SafeWaitHandle?safeWaitHandle = null; try { safeWaitHandle = new SafeWaitHandle(handle, ownsHandle: true); return(safeWaitHandle); } finally { if (safeWaitHandle == null) { HandleManager.DeleteHandle(handle); } } }
private static SafeWaitHandle NewHandle(WaitableObject waitableObject) { var safeWaitHandle = new SafeWaitHandle(); IntPtr handle = IntPtr.Zero; try { handle = HandleManager.NewHandle(waitableObject); } finally { if (handle == IntPtr.Zero) { waitableObject.OnDeleteHandle(); } } Marshal.InitHandle(safeWaitHandle, handle); return(safeWaitHandle); }
//Vector3 B = new Vector3(1/8, 1/8, 1/8); // Use this for initialization void Start() { this.socket = ScriptableObject.CreateInstance <SocketImpedance>(); this.force = Vector3.zero; // force vector to be sent to haptic interface // Getting proxy Rigidbody and its parameters this.rb = GetComponent <Rigidbody>(); this.m = this.rb.mass; // Computing dampening (stability) this.b = 2f * (float)Math.Pow(this.k * this.m, 0.5f); print("INIT:: Coefficients: k = " + this.k + ", b = " + this.b); // Getting Handle GameObject and its script handle = GameObject.Find("Handle"); handleScript = this.handle.GetComponent <HandleManager>(); // Initialize position of handle and proxy to avoid huge forces // at the start of the game this.rb.position = this.sizeFactor * (socket.GetPosition()); handle.transform.position = this.sizeFactor * (socket.GetPosition()); print("INIT:: Haptics Done"); }
public static bool SignalAndWait(IntPtr handleToSignal, IntPtr handleToWaitOn, int timeoutMilliseconds) { Debug.Assert(timeoutMilliseconds >= -1); ThreadWaitInfo waitInfo = RuntimeThread.CurrentThread.WaitInfo; // A pending interrupt does not signal the specified handle if (waitInfo.CheckAndResetPendingInterrupt) { throw new ThreadInterruptedException(); } WaitableObject waitableObjectToSignal = HandleManager.FromHandle(handleToSignal); WaitableObject waitableObjectToWaitOn = HandleManager.FromHandle(handleToWaitOn); bool waitCalled = false; s_lock.Acquire(); try { waitableObjectToSignal.Signal(1); waitCalled = true; return(waitableObjectToWaitOn.Wait_Locked(waitInfo, timeoutMilliseconds)); } finally { // Once the wait function is called, it will release the lock if (waitCalled) { s_lock.VerifyIsNotLocked(); } else { s_lock.Release(); } } }
private void CloseMutex() { for (var i = 0; i < 10; i++) { #if DEBUG System.Diagnostics.Debug.Print("Mutex Kill Attempt Nr" + i); #endif try { //if (HandleManager.ClearMutex(ClientManager.ClientInfo.ProcessName, "AN-Mutex-Window-Guild Wars 2", ref nomutexpros)) i = 10; if (HandleManager.KillHandle(Process, "AN-Mutex-Window-Guild Wars 2", false)) { i = 10; } } catch (Exception err) { MessageBox.Show("Mutex release failed, will try again. Please provide the following if you want to help fix this problem: \r\n" + err.GetType().ToString() + "\r\n" + err.Message + "\r\n" + err.StackTrace); } //Maxtime 10 secs Thread.Sleep((int)(Math.Pow(i, 2) * 25 + 50)); } }
public static int Wait( Span <IntPtr> waitHandles, bool waitForAll, int timeoutMilliseconds) { Debug.Assert(waitHandles != null); Debug.Assert(waitHandles.Length > 0); Debug.Assert(waitHandles.Length <= WaitHandle.MaxWaitHandles); Debug.Assert(timeoutMilliseconds >= -1); ThreadWaitInfo waitInfo = Thread.CurrentThread.WaitInfo; WaitableObject?[] waitableObjects = waitInfo.GetWaitedObjectArray(waitHandles.Length); bool success = false; try { for (int i = 0; i < waitHandles.Length; ++i) { Debug.Assert(waitHandles[i] != IntPtr.Zero); WaitableObject waitableObject = HandleManager.FromHandle(waitHandles[i]); if (waitForAll) { // Check if this is a duplicate, as wait-for-all does not support duplicates. Including the parent // loop, this becomes a brute force O(n^2) search, which is intended since the typical array length is // short enough that this would actually be faster than other alternatives. Also, the worst case is not // so bad considering that the array length is limited by <see cref="WaitHandle.MaxWaitHandles"/>. for (int j = 0; j < i; ++j) { if (waitableObject == waitableObjects[j]) { throw new DuplicateWaitObjectException("waitHandles[" + i + ']'); } } } waitableObjects[i] = waitableObject; } success = true; } finally { if (!success) { for (int i = 0; i < waitHandles.Length; ++i) { waitableObjects[i] = null; } } } if (waitHandles.Length == 1) { WaitableObject waitableObject = waitableObjects[0] !; waitableObjects[0] = null; return (waitableObject.Wait(waitInfo, timeoutMilliseconds, interruptible: true, prioritize: false)); } return (WaitableObject.Wait( waitableObjects, waitHandles.Length, waitForAll, waitInfo, timeoutMilliseconds, interruptible: true, prioritize: false)); }
public static int Wait(IntPtr handle, int timeoutMilliseconds, bool interruptible) { Debug.Assert(timeoutMilliseconds >= -1); return(Wait(HandleManager.FromHandle(handle), timeoutMilliseconds, interruptible)); }
public static void ReleaseMutex(IntPtr handle) { ReleaseMutex(HandleManager.FromHandle(handle)); }
public static int ReleaseSemaphore(IntPtr handle, int count) { Debug.Assert(count > 0); return(ReleaseSemaphore(HandleManager.FromHandle(handle), count)); }
public static void ResetEvent(IntPtr handle) { ResetEvent(HandleManager.FromHandle(handle)); }
public static void DeleteHandle(IntPtr handle) { HandleManager.DeleteHandle(handle); }
public static int Wait( RuntimeThread currentThread, SafeWaitHandle[] safeWaitHandles, WaitHandle[] waitHandles, bool waitForAll, int timeoutMilliseconds) { Debug.Assert(currentThread == RuntimeThread.CurrentThread); Debug.Assert(safeWaitHandles != null); Debug.Assert(safeWaitHandles.Length >= waitHandles.Length); Debug.Assert(waitHandles.Length > 0); Debug.Assert(waitHandles.Length <= WaitHandle.MaxWaitHandles); Debug.Assert(timeoutMilliseconds >= -1); ThreadWaitInfo waitInfo = currentThread.WaitInfo; if (waitInfo.CheckAndResetPendingInterrupt) { throw new ThreadInterruptedException(); } int count = waitHandles.Length; WaitableObject[] waitableObjects = waitInfo.GetWaitedObjectArray(count); bool success = false; try { for (int i = 0; i < count; ++i) { Debug.Assert(safeWaitHandles[i] != null); WaitableObject waitableObject = HandleManager.FromHandle(safeWaitHandles[i].DangerousGetHandle()); if (waitForAll) { /// Check if this is a duplicate, as wait-for-all does not support duplicates. Including the parent /// loop, this becomes a brute force O(n^2) search, which is intended since the typical array length is /// short enough that this would actually be faster than other alternatives. Also, the worst case is not /// so bad considering that the array length is limited by <see cref="WaitHandle.MaxWaitHandles"/>. for (int j = 0; j < i; ++j) { if (waitableObject == waitableObjects[j]) { throw new DuplicateWaitObjectException("waitHandles[" + i + ']'); } } } waitableObjects[i] = waitableObject; } success = true; } finally { if (!success) { for (int i = 0; i < count; ++i) { waitableObjects[i] = null; } } } if (count == 1) { WaitableObject waitableObject = waitableObjects[0]; waitableObjects[0] = null; return(waitableObject.Wait(waitInfo, timeoutMilliseconds) ? 0 : WaitHandle.WaitTimeout); } return (WaitableObject.Wait( waitableObjects, count, waitForAll, waitInfo, timeoutMilliseconds, waitHandles)); }
protected ActionBase() { Handles = new HandleManager(); }
public static bool Wait(IntPtr handle, int timeoutMilliseconds) { Debug.Assert(timeoutMilliseconds >= -1); return(Wait(HandleManager.FromHandle(handle), timeoutMilliseconds)); }