/// <summary> /// Create new tray icon. /// </summary>s /// <param name="productName">Product name.</param> /// <param name="virtualDrive">VirtualDriveBase, need to get syncService and fileSystemMonitor.</param> /// <param name="exitEvent">ManualResetEvent, used to stop application.</param> /// <returns></returns> public static Thread CreateTrayInterface(string productName, IVirtualDrive virtualDrive, ConsoleManager.ConsoleExitEvent exitEvent) { // Start tray application. Thread thread = new Thread(() => { WindowsTrayInterface windowsTrayInterface = new WindowsTrayInterface($"{productName}", virtualDrive); Application.Run(); exitEvent.Set(); }); thread.SetApartmentState(ApartmentState.STA); thread.Start(); thread.IsBackground = true; return(thread); }
/// <summary> /// Create new tray icon. /// </summary> /// <param name="productName">Product name.</param> /// <param name="syncService">Sync service</param> /// <param name="exitEvent">ManualResetEvent, used to stop application</param> /// <returns></returns> public static Thread CreateTrayInterface(string productName, FullSyncService syncService, ManualResetEvent exitEvent) { // Start tray application. Thread thread = new Thread(() => { WindowsTrayInterface windowsTrayInterface = new WindowsTrayInterface($"{productName}", syncService); syncService.syncEvent += windowsTrayInterface.HandleStatusChange; Application.Run(); exitEvent.Set(); }); thread.SetApartmentState(ApartmentState.STA); thread.Start(); thread.IsBackground = true; return(thread); }