~ubuntu-branches/ubuntu/oneiric/monodevelop/oneiric

« back to all changes in this revision

Viewing changes to src/core/MonoDevelop.Projects.Formats.MSBuild/Main.cs

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2011-06-27 17:03:13 UTC
  • mto: (1.8.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 54.
  • Revision ID: james.westby@ubuntu.com-20110627170313-6cvz3s19x6e9hqe9
ImportĀ upstreamĀ versionĀ 2.5.92+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
using System.Runtime.Serialization.Formatters.Binary;
30
30
using System.Runtime.Remoting;
31
31
using System.Runtime.Remoting.Channels;
32
 
using System.Runtime.Remoting.Channels.Ipc;
 
32
using System.Runtime.Remoting.Channels.Tcp;
33
33
using System.Threading;
34
34
using System.Diagnostics;
35
35
 
37
37
{
38
38
        class MainClass
39
39
        {
40
 
                static string unixRemotingFile;
41
40
                static ManualResetEvent exitEvent = new ManualResetEvent (false);
42
41
                
43
42
                public static void Main (string[] args)
58
57
                                        System.Threading.Thread.Sleep (400);
59
58
                                }
60
59
                                
61
 
                                if (unixRemotingFile != null && File.Exists (unixRemotingFile))
62
 
                                        File.Delete (unixRemotingFile);
63
60
                        } catch (Exception ex) {
64
61
                                Console.WriteLine (ex);
65
62
                        }
70
67
                        IDictionary dict = new Hashtable ();
71
68
                        BinaryClientFormatterSinkProvider clientProvider = new BinaryClientFormatterSinkProvider();
72
69
                        BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider();
73
 
                        unixRemotingFile = Path.GetTempFileName ();
74
 
                        dict ["portName"] = Path.GetFileName (unixRemotingFile);
 
70
                        dict ["port"] = 0;
 
71
                        dict ["rejectRemoteRequests"] = true;
75
72
                        serverProvider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
76
 
                        ChannelServices.RegisterChannel (new IpcChannel (dict, clientProvider, serverProvider), false);
 
73
                        ChannelServices.RegisterChannel (new TcpChannel (dict, clientProvider, serverProvider), false);
77
74
                }
78
75
                
79
76
                public static void WatchProcess (string procId)
83
80
                                while (true) {
84
81
                                        Thread.Sleep (1000);
85
82
                                        try {
86
 
                                                // Throws exception if process is not running
87
 
                                                Process.GetProcessById (id);
 
83
                                                // Throws exception if process is not running.
 
84
                                                // When watching a .NET process from Mono, GetProcessById may
 
85
                                                // return the process with HasExited=true
 
86
                                                Process p = Process.GetProcessById (id);
 
87
                                                if (p.HasExited)
 
88
                                                        break;
88
89
                                        }
89
90
                                        catch {
90
 
                                                exitEvent.Set ();
91
91
                                                break;
92
92
                                        }
93
93
                                }
 
94
                                exitEvent.Set ();
94
95
                        });
95
96
                        t.IsBackground = true;
96
97
                        t.Start ();