Ejemplo n.º 1
0
 public static void RefreshProcessCollection()
 {
     foreach (Process process in Process.GetProcesses())
     {
         if (!IsProcessIDInCollection(process.Id) && (process.MainWindowHandle != IntPtr.Zero))
         {
             ProcessItem item = new ProcessItem(process);
             _processList.Add(item);
             if (ProcessItemAdded != null)
             {
                 ProcessItemAdded(null, new ProcessManagerEventArgs(item));
             }
         }
     }
     for (int i = 0; i < _processList.Count; i++)
     {
         ProcessItem item = _processList[i];
         try
         {
             item.Process.Refresh();
             if (item.Process.HasExited)
             {
                 _processList.Remove(item);
                 if (ProcessItemRemoved != null)
                 {
                     ProcessItemRemoved(null, new ProcessManagerEventArgs(item));
                 }
                 item.Dispose();
             }
         }
         catch (Exception)
         {
         }
     }
 }
Ejemplo n.º 2
0
        protected override void RemoveProcess(Message message)
        {
            if (message != null)
            {
                String data = message.Text;
                int    processID;

                if (Int32.TryParse(data, out processID))
                {
                    ProcessPrototype process = ProcessCollection.FirstOrDefault(x => x.ID == processID);

                    if (process != null)
                    {
                        Application.Current.Dispatcher.BeginInvoke(
                            DispatcherPriority.Background,
                            new Action(() =>
                        {
                            ProcessCollection.Remove(process);
                        }));
                    }

                    if (SelectedPrototype != null && SelectedPrototype.ID == processID)
                    {
                        SelectedPrototype = null;
                        RefreshProperties();
                    }
                }
            }
        }
Ejemplo n.º 3
0
        bool Terminated(Process p, ProcessCollection infos, bool wait = false)
        {
            Exception ex = null;

            try {
                if (!p.HasExited && !wait)
                {
                    return(false);
                }
            } catch {
                if (!wait)
                {
                    return(false);
                }
            }

            p.WaitForExit();

            ProcessInfo info;

            lock (infos) {
                if (!infos.Contains(p))
                {
                    return(true);
                }
                info = infos[p];
                infos.Remove(info);
            }

            if (WCF)
            {
            }

            if ((p.ExitCode == 0 || (WCF && (p.ExitCode == 3 || p.ExitCode == 4))) && File.Exists(info.File) && File.GetLastWriteTimeUtc(info.File) > info.StartTime)
            {
                if (Clean)
                {
                    CleanXmlTypeDefinitions(info.File);
                }
                RemovePortInProxyUrl(info.File, info.Url);
                Log.LogMessage(MessageImportance.High, "Generated proxy class for {0}", new Uri(info.Url).AbsolutePath);
            }
            else
            {
                var cmd = p.StandardOutput.ReadToEnd();
                Log.LogError("Error generating proxy for {0}: {1} {2}; {3}", new Uri(info.Url).AbsolutePath, WSE ? "wsewsdl3.exe" : (WCF ? "scvutil.exe" : "wsdl.exe"), info.Args, cmd.Replace("\n", ", ").Replace("\r", ""));
                Log.LogCommandLine(cmd);
            }
            return(true);
        }