This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// <summary> | |
| /// Hooks into a Http Request's context, to set an action that | |
| /// will fire as that request is ending. | |
| /// <para></para> | |
| /// When the hook action fires, the context will be closed, so no response | |
| /// data can be sent, but clean-up or write-back actions within the server | |
| /// will be honoured | |
| /// </summary> | |
| public class RequestHook | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static class ControlHelper { | |
| public static void Suspend(Control c) { | |
| if (c == null || c.IsDisposed || !c.IsHandleCreated) return; | |
| Win32.SendMessage(c.Handle, 0x00B, (IntPtr)0, IntPtr.Zero); | |
| } | |
| public static void Resume(Control c) { | |
| if (c == null || c.IsDisposed || !c.IsHandleCreated) return; | |
| Win32.SendMessage(c.Handle, 0x00B, (IntPtr)1, IntPtr.Zero); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// <summary> | |
| /// Logarithmic record of good and bad calls per second | |
| /// </summary> | |
| internal class Timeslice | |
| { | |
| private readonly long[] sampleSum; | |
| private readonly int[] sampleCount; | |
| private readonly long ticksPerSample; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static class Utils | |
| { | |
| public static int SizeOf<T>(T obj) | |
| { | |
| return SizeOfCache<T>.SizeOf; | |
| } | |
| private static class SizeOfCache<T> | |
| { | |
| // ReSharper disable once StaticMemberInGenericType |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.ComponentModel; | |
| using System.Diagnostics; | |
| using System.Runtime.InteropServices; | |
| namespace ProxyParent | |
| { | |
| /// <summary> | |
| /// Allows processes to be automatically killed if this parent process unexpectedly quits. | |
| /// This feature requires Windows 8 or greater. On Windows 7, nothing is done.</summary> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using (var f = new FileStream(processIdPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) | |
| { | |
| using (var m = MemoryMappedFile.CreateFromFile(f, null, 0, MemoryMappedFileAccess.Read, null, HandleInheritability.None, true)) | |
| { | |
| using (var s = m.CreateViewStream(0, 0, MemoryMappedFileAccess.Read)) | |
| { | |
| using (var r = new StreamReader(s)) | |
| { | |
| var l = r.ReadToEnd(); | |
| Console.WriteLine(l); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// <summary> | |
| /// Helper class to properly wait for async tasks | |
| /// </summary> | |
| public static class Sync | |
| { | |
| private static readonly TaskFactory _taskFactory = new | |
| TaskFactory(CancellationToken.None, | |
| TaskCreationOptions.None, | |
| TaskContinuationOptions.None, | |
| TaskScheduler.Default); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| F01DAB1E-FACE-BEEF-FEED-C1A551F1AB1E |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| QT_QPA_PLATFORMTHEME= openscad |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private static WebClient WebClientWithProxy_Net46() { | |
| var client = new WebClient(); | |
| var defaultProxy = WebRequest.DefaultWebProxy; | |
| if (defaultProxy == null) return client; | |
| defaultProxy.Credentials = CredentialCache.DefaultCredentials; | |
| client.Proxy = defaultProxy; | |
| return client; | |
| } |