Inheritance: System.MarshalByRefObject
Esempio n. 1
0
        public DeOpsMutex(AppContext context, string[] args)
        {
            try
            {
                string name = "DeOps" + Application.ProductVersion;

                TheMutex = new Mutex(true, name, out First);

                string objectName = "SingleInstanceProxy";
                string objectUri = "ipc://" + name + "/" + objectName;

                if (First)
                {
                    IpcChannel = new IpcServerChannel(name);
                    ChannelServices.RegisterChannel(IpcChannel, false);
                    RemotingConfiguration.RegisterWellKnownServiceType(typeof(IpcObject), objectName, WellKnownObjectMode.Singleton);

                    IpcObject obj = new IpcObject();
                    obj.NewInstance += context.SecondInstanceStarted;

                    RemotingServices.Marshal(obj, objectName);
                }

                else
                {
                    IpcChannel = new IpcClientChannel();
                    ChannelServices.RegisterChannel(IpcChannel, false);

                    IpcObject obj = Activator.GetObject(typeof(IpcObject), objectUri) as IpcObject;

                    obj.SignalNewInstance(args);
                }
            }
            catch { }
        }
Esempio n. 2
0
        public DeOpsMutex(AppContext context, string[] args)
        {
            try
            {
                string host = "DeOps_" + DeOpsContext.CoreVersion.ToString();

                TheMutex = new Mutex(true, host, out First);

                string objectUri = "SingleInstanceProxy";
                string url       = "ipc://" + host + "/" + objectUri;



                if (First)
                {
                    DeOpsChannel = new IpcServerChannel(host);

                    ChannelServices.RegisterChannel(DeOpsChannel, false);
                    RemotingConfiguration.RegisterWellKnownServiceType(typeof(IpcObject), objectUri, WellKnownObjectMode.Singleton);

                    IpcObject obj = new IpcObject();
                    obj.NewInstance += context.SecondInstanceStarted;

                    RemotingServices.Marshal(obj, objectUri);
                }

                else
                {
                    DeOpsChannel = new IpcClientChannel();
                    ChannelServices.RegisterChannel(DeOpsChannel, false);

                    IpcObject obj = Activator.GetObject(typeof(IpcObject), url) as IpcObject;

                    obj.SignalNewInstance(args);
                }
            }
            catch { }
        }
Esempio n. 3
0
        public DeOpsMutex(AppContext context, string[] args)
        {
            try
            {
                string host = "DeOps_" + DeOpsContext.CoreVersion.ToString();

                TheMutex = new Mutex(true, host, out First);

                string objectUri = "SingleInstanceProxy";
                string url = "ipc://" + host + "/" + objectUri;

                if (First)
                {
                    DeOpsChannel = new IpcServerChannel(host);

                    ChannelServices.RegisterChannel(DeOpsChannel, false);
                    RemotingConfiguration.RegisterWellKnownServiceType(typeof(IpcObject), objectUri, WellKnownObjectMode.Singleton);

                    IpcObject obj = new IpcObject();
                    obj.NewInstance += context.SecondInstanceStarted;

                    RemotingServices.Marshal(obj, objectUri);
                }

                else
                {
                    DeOpsChannel = new IpcClientChannel();
                    ChannelServices.RegisterChannel(DeOpsChannel, false);

                    IpcObject obj = Activator.GetObject(typeof(IpcObject), url) as IpcObject;

                    obj.SignalNewInstance(args);
                }
            }
            catch { }
        }