/// <summary> /// Run a second message pump that will filter messages asyncronously /// </summary> /// <param name="provideHandle">A delegate that provide a window handle for /// resource initializing</param> /// <param name="messageFilter">A delegate for message filtering</param> /// <param name="cleanResources">A delegate for proper resource cleaning /// before quitting the loop</param> /// <param name="background">State if the loop should be run on a background /// thread or not. If background = false, please be aware of the /// possible race conditions on application shut-down.</param> public MessageLoop(HandleProvider provideHandle, MessageFilter messageFilter, HandleProvider cleanResources, bool background) { _Lock = new Object(); _ResourceCleaner = cleanResources; _Completion = new ManualResetEvent(false); _Disposed = false; Thread thread = new Thread(delegate() { _ApplicationContext = new ApplicationContext(); Form form = new Form(); provideHandle(form.Handle); _WindowHandle = form.Handle; _MessageFilter = new CustomMessageFilter(messageFilter); Application.AddMessageFilter(_MessageFilter); _Completion.Set(); // If background = true we do proper resource cleaning on ProcessExit // event if (background) { AppDomain.CurrentDomain.ProcessExit += new EventHandler(CurrentDomain_ProcessExit); } Application.Run(_ApplicationContext); }); thread.SetApartmentState(ApartmentState.STA); thread.IsBackground = background; thread.Start(); _Completion.WaitOne(); }
/// <summary> /// Run a second message pump that will filter messages asyncronously /// </summary> /// <param name="provideHandle">A delegate that provide a window handle for /// resource initializing</param> /// <param name="messageFilter">A delegate for message filtering</param> /// <param name="cleanResources">A delegate for proper resource cleaning /// before quitting the loop</param> /// <param name="background">State if the loop should be run on a background /// thread or not. If background = false, please be aware of the /// possible race conditions on application shut-down.</param> public MessageLoop(HandleProvider initializeResources, MessageFilter messageFilter, HandleProvider cleanResources, bool background) { _Lock = new Object(); _ResourceCleaner = cleanResources; _Completion = new ManualResetEvent(false); _Disposed = false; Thread thread = new Thread(delegate() { _ApplicationContext = new ApplicationContext(); Form form = new Form(); initializeResources(form.Handle); _MessageFilter = new CustomMessageFilter(messageFilter); Application.AddMessageFilter(_MessageFilter); // Signal resources initalizated _Completion.Set(); // If background = true, do resource cleaning on ProcessExit event if (background) { AppDomain.CurrentDomain.ProcessExit += new EventHandler(CurrentDomain_ProcessExit); } // Run the message loop Application.Run(_ApplicationContext); // Clean resource before leaving the thread cleanResources(form.Handle); // Signal resources cleaned _Completion.Set(); }); thread.SetApartmentState(ApartmentState.STA); thread.IsBackground = background; thread.Start(); // Before returning the instace, wait for thread resources initialization _Completion.WaitOne(); }
public MessageLoop(HandleProvider provideHandle, MessageFilter messageFilter, HandleProvider cleanResource) { _ResourceCleaner = cleanResource; _Completion = new ManualResetEvent(false); _Disposed = false; Thread thread = new Thread(delegate() { _ApplicationContext = new ApplicationContext(); _ApplicationContext.ThreadExit += new EventHandler(_ApplicationContext_ThreadExit); _Completion.Set(); Form form = new Form(); provideHandle(form.Handle); _WindowHandle = form.Handle; _MessageFilter = new CustomMessageFilter(messageFilter); Application.AddMessageFilter(_MessageFilter); Application.Run(_ApplicationContext); }); thread.SetApartmentState(ApartmentState.STA); thread.IsBackground = true; thread.Start(); }
/// <summary> /// Use this method to provide a the proper Window Handle to bind with the right window. /// If you don't set this, then FastFind will work on FullScreen. /// </summary> /// <param name="provider"></param> static public void SetHWndProvider(HandleProvider provider) { CustomProvider = provider; }
private void InitializeProviders() { listThreads.BeginUpdate(); _threadP = new ThreadProvider(_pid); Program.SecondaryProviderThread.Add(_threadP); _threadP.Updated += this._threadP_Updated; listThreads.Provider = _threadP; listModules.BeginUpdate(); _moduleP = new ModuleProvider(_pid); Program.SecondaryProviderThread.Add(_moduleP); _moduleP.Updated += this._moduleP_Updated; listModules.Provider = _moduleP; listMemory.BeginUpdate(); _memoryP = new MemoryProvider(_pid); Program.SecondaryProviderThread.Add(_memoryP); _memoryP.IgnoreFreeRegions = true; _memoryP.Updated += this._memoryP_Updated; listMemory.Provider = _memoryP; listHandles.BeginUpdate(); _handleP = new HandleProvider(_pid); Program.SecondaryProviderThread.Add(_handleP); _handleP.HideHandlesWithNoName = Settings.Instance.HideHandlesWithNoName; _handleP.Updated += this._handleP_Updated; listHandles.Provider = _handleP; this.InitializeShortcuts(); }
private void checkHideHandlesNoName_CheckedChanged(object sender, EventArgs e) { if (_handleP != null) { checkHideHandlesNoName.Enabled = false; this.Cursor = Cursors.WaitCursor; Program.SecondaryProviderThread.Remove(_handleP); _handleP.Dispose(); listHandles.BeginUpdate(); _handleP = new HandleProvider(_pid); Program.SecondaryProviderThread.Add(_handleP); _handleP.HideHandlesWithNoName = checkHideHandlesNoName.Checked; _handleP.Updated += new HandleProvider.ProviderUpdateOnce(_handleP_Updated); _handleP.Boost(); listHandles.Provider = _handleP; _handleP.Enabled = true; } }
private void InitializeProviders() { listThreads.BeginUpdate(); _threadP = new ThreadProvider(_pid); Program.SecondarySharedThreadProvider.Add(_threadP); _threadP.Interval = Properties.Settings.Default.RefreshInterval; _threadP.Updated += new ThreadProvider.ProviderUpdateOnce(_threadP_Updated); listThreads.Provider = _threadP; listModules.BeginUpdate(); _moduleP = new ModuleProvider(_pid); Program.SecondarySharedThreadProvider.Add(_moduleP); _moduleP.Interval = Properties.Settings.Default.RefreshInterval; _moduleP.Updated += new ModuleProvider.ProviderUpdateOnce(_moduleP_Updated); listModules.Provider = _moduleP; listMemory.BeginUpdate(); _memoryP = new MemoryProvider(_pid); Program.SecondarySharedThreadProvider.Add(_memoryP); _memoryP.IgnoreFreeRegions = true; _memoryP.Interval = Properties.Settings.Default.RefreshInterval; _memoryP.Updated += new MemoryProvider.ProviderUpdateOnce(_memoryP_Updated); listMemory.Provider = _memoryP; listHandles.BeginUpdate(); _handleP = new HandleProvider(_pid); Program.SecondarySharedThreadProvider.Add(_handleP); _handleP.HideHandlesWithNoName = Properties.Settings.Default.HideHandlesWithNoName; _handleP.Interval = Properties.Settings.Default.RefreshInterval; _handleP.Updated += new HandleProvider.ProviderUpdateOnce(_handleP_Updated); listHandles.Provider = _handleP; listThreads.List.SetTheme("explorer"); listModules.List.SetTheme("explorer"); listMemory.List.SetTheme("explorer"); listHandles.List.SetTheme("explorer"); this.InitializeShortcuts(); }
private void checkHideHandlesNoName_CheckedChanged(object sender, EventArgs e) { if (_handleP != null) { checkHideHandlesNoName.Enabled = false; this.Cursor = Cursors.WaitCursor; Program.SecondarySharedThreadProvider.Remove(_handleP); _handleP.Dispose(); listHandles.BeginUpdate(); _handleP = new HandleProvider(_pid); Program.SecondarySharedThreadProvider.Add(_handleP); _handleP.HideHandlesWithNoName = checkHideHandlesNoName.Checked; _handleP.Interval = Properties.Settings.Default.RefreshInterval; _handleP.Updated += new HandleProvider.ProviderUpdateOnce(_handleP_Updated); _handleP.RunOnceAsync(); listHandles.Provider = _handleP; _handleP.Enabled = true; } }