private static void BackgroundWorkerAsyncRequest_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { WallpaperBgWorker my_WallpaperBgWorker = (WallpaperBgWorker)sender; WallpaperBgWorker try_WallpaperBgWorker; dictionaryBag.TryRemove(my_WallpaperBgWorker.Key, out try_WallpaperBgWorker); // IdentifyQueryBackground identifiedQuery = null; // identifiedQuery = (IdentifyQueryBackground)e.Result; }
internal static void StopBackgowndWorkProcess() { if (m_BackgroundWorkerAsync.IsBusy == true) { m_BackgroundWorkerAsync.CancelAsync(); m_BackgroundWorkerAsync.Abort(); m_BackgroundWorkerAsync.Dispose(); m_BackgroundWorkerAsync = null; } }
public static void StartBackgowndWorkProcess(IdentifyQueryBackground param) { try { if (m_BackgroundWorkerAsync != null) { m_BackgroundWorkerAsync.CancelAsync(); m_BackgroundWorkerAsync.Abort(); } m_BackgroundWorkerAsync = new WallpaperBgWorker(); m_BackgroundWorkerAsync.WorkerSupportsCancellation = true; m_BackgroundWorkerAsync.DoWork += new DoWorkEventHandler(BackgroundWorkerAsyncRequest_DoWork); m_BackgroundWorkerAsync.RunWorkerCompleted += new RunWorkerCompletedEventHandler(BackgroundWorkerAsyncRequest_RunWorkerCompleted); m_BackgroundWorkerAsync.RunWorkerAsync(param); dictionaryBag.TryAdd(m_BackgroundWorkerAsync.Key, m_BackgroundWorkerAsync); } catch (Exception) { } }
private static void BackgroundWorkerAsyncRequest_DoWork(object sender, DoWorkEventArgs e) { try { WallpaperBgWorker my_BackgroundWorkerAsync = (WallpaperBgWorker)sender; IdentifyQueryBackground identifiedQuery = null; identifiedQuery = (IdentifyQueryBackground)e.Argument; images.Clear(); getFileList(images, identifiedQuery.directoryPatch); while (true) { try { Random rnd = new Random(); int currentImage = rnd.Next(0, images.Count); String image = images[currentImage]; Wallpaper.Set(image, identifiedQuery.style); my_BackgroundWorkerAsync.Sleep(identifiedQuery.timeout); } catch (Exception ex) { } if (my_BackgroundWorkerAsync.CancellationPending) { e.Cancel = true; return; } } } catch (Exception ex) { } }