Beispiel #1
0
        private void ListUpdateThread()
        {
            while (true)
            {
                foreach (ProcessWrapper p in processes)
                {
                    p.Process.Refresh();
                }

                foreach (Process p in Process.GetProcesses())
                {
                    if (processes.Exists(x => p.Id == x.Process.Id))
                    {
                        continue;
                    }

                    if (IsD2Window(p))
                    {
                        ProcessWrapper pw = new ProcessWrapper(p);
                        processes.Add(pw);
                        p.Exited += delegate { processes.Remove(pw); };
                        if (GetAutoload())
                        {
                            p.WaitForInputIdle();
                            Attach(pw);
                        }
                    }
                }
                Processes.Invoke((MethodInvoker) delegate {
                    ((CurrencyManager)Processes.BindingContext[Processes.DataSource]).Refresh();
                });
                System.Threading.Thread.Sleep(400);
            }
        }
Beispiel #2
0
        private void ListUpdateThread()
        {
            while (true)
            {
                foreach (ProcessWrapper p in processes)
                {
                    p.Process.Refresh();
                }

                processes.RemoveAll(x => x.Process.HasExited);

                foreach (Process p in Process.GetProcesses())
                {
                    if (processes.Exists(x => p.Id == x.Process.Id))
                    {
                        continue;
                    }

                    string moduleName = "";
                    try {
                        moduleName = Path.GetFileName(p.MainModule.FileName).ToLowerInvariant();
                    } catch { }
                    string classname = GetLCClassName(p);
                    if (!String.IsNullOrEmpty(classname) && classname == "diablo ii" &&
                        (moduleName == "game.exe" || moduleName.Contains("d2loader") ||
                         moduleName.Contains("d2launcher")))
                    {
                        ProcessWrapper pw = new ProcessWrapper(p);
                        processes.Add(pw);
                        if (GetAutoload())
                        {
                            p.WaitForInputIdle();
                            Attach(pw);
                        }
                    }
                }
                Processes.Invoke((MethodInvoker) delegate {
                    ((CurrencyManager)Processes.BindingContext[Processes.DataSource]).Refresh();
                });
                System.Threading.Thread.Sleep(400);
            }
        }