Ejemplo n.º 1
0
 public SystemForegroundTitleListener()
 {
     _HandleSystemForegroundEvent = HandleSystemForegroundEvent;
     _HandleObjectNamechangeEvent = HandleObjectNamechangeEvent;
     Refs.Set(ref hFocusedApplicationEvent,
              SetWinEventHook(Api.EVENT_SYSTEM_FOREGROUND, _HandleSystemForegroundEvent));
 }
 private SingleFileRowWriter EnsureOpenedLogFile(string fileName)
 {
     if (writer == null || writer.OpenedFile != fileName)
     {
         Refs.Set(ref writer, OpenLogFile(fileName));
     }
     return(writer);
 }
Ejemplo n.º 3
0
 protected virtual void Dispose(bool disposing)
 {
     Refs.Dispose(hFocusedApplicationEvent);
     Refs.Dispose(hWindowTitleChangeEvent);
     // TODO: we must find a way to keep those delegate references alive. Ts there really no way in .NET to really keep these delegates from being collected?
     // Putting GC.KeepAlive will at least prevent the compiler from optimizing out the field references, but it is still possible that the delegate is collected earlier
     // during a gc run
     GC.KeepAlive(_HandleSystemForegroundEvent);
     GC.KeepAlive(_HandleObjectNamechangeEvent);
 }
Ejemplo n.º 4
0
        private void HandleSystemForegroundEvent(IntPtr hWinEventHook, uint eventType, IntPtr hwnd, int idObject, int idChild, uint dwEventThread, uint dwmsEventTime)
        {
            if (hwnd == previousHwnd)
            {
                return;
            }
            var threadId = Api.GetWindowThreadProcessId(hwnd, out var processId);

            Refs.Set(ref hWindowTitleChangeEvent,
                     SetWinEventHook(Api.EVENT_OBJECT_NAMECHANGE, processId, threadId, _HandleObjectNamechangeEvent));
            previousHwnd = hwnd;
            FireForegroundTitleProbablyChanged();
        }
Ejemplo n.º 5
0
 protected virtual void Dispose(bool disposing)
 {
     Refs.Dispose(CsvWriter);
 }
Ejemplo n.º 6
0
 private void FireForegroundTitleProbablyChanged()
 {
     Refs.Fire(ForegroundTitleProbablyChanged);
 }
Ejemplo n.º 7
0
 private void DisposeNonDesigner(bool disposing)
 {
     Refs.Dispose(systemFocusTitleListener);
 }
Ejemplo n.º 8
0
 private void ActivityMonitorMainForm_FormClosed(object sender, FormClosedEventArgs e)
 {
     Refs.Dispose(rowWriter);
 }