/// <summary> /// Default constructor. /// </summary> internal XDIOStreamListener() { this.watcherList = new Dictionary <string, FileSystemWatcher>(StringComparer.InvariantCultureIgnoreCase); // ensure there is a network watcher for this mode, the implementation ensures only one is active at // any one time this.networkRelay = new NetworkRelayListener(XDBroadcast.CreateBroadcast(XDTransportMode.IOStream), XDListener.CreateListener(XDTransportMode.MailSlot)); }
public static void StartPrcMessaging() { if (_broadcast != null) { return; } _broadcast = XDBroadcast.CreateBroadcast(XDTransportMode.WindowsMessaging, false); _listener = XDListener.CreateListener(XDTransportMode.WindowsMessaging); _listener.MessageReceived += Listener_MessageReceived; _listener.RegisterChannel(channel); }
/// <summary> /// Default constructor. /// </summary> public TestService() { InitializeComponent(); this.ServiceName = "Test Service"; //only the following mode is supported in windows services broadcast = XDBroadcast.CreateBroadcast(XDTransportMode.IOStream); listener = XDListener.CreateListener(XDTransportMode.IOStream); listener.MessageReceived += new XDListener.XDMessageHandler(OnMessageReceived); listener.RegisterChannel("Status"); listener.RegisterChannel("Channel1"); listener.RegisterChannel("Channel2"); }
public CommManager() { this.otherInstances = new List <LogViewerInstance>(); this.listener = XDListener.CreateListener(XDTransportMode.WindowsMessaging); this.broadcast = XDBroadcast.CreateBroadcast(XDTransportMode.WindowsMessaging, false); this.listener.RegisterChannel(myID.ToString()); //Channel only for me this.listener.RegisterChannel(ChannelBroadcast); //Channel for everyone listener.MessageReceived += new XDListener.XDMessageHandler(listener_MessageReceived); this.MainWindowHandle = System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle; }
public static bool BeginProfiling(string dataProvider, string channel) { IDataProvider provider = tgProviderFactory.Factory.GetDataProvider(dataProvider, "DataProvider"); if (provider != null) { if (!provider.IsTracing) { // create an instance of IXDBroadcast using the given mode, // note IXDBroadcast does not implement IDisposable broadcast = XDBroadcast.CreateBroadcast(XDTransportMode.IOStream); provider.TraceChannel = channel; provider.TraceHandler += profileListener.MyTraceEventHandler; } } return(true); }
/// <summary> /// Initialize the broadcast and listener mode. /// </summary> /// <param name="mode">The new mode.</param> public static void InitializeMode(XDTransportMode mode) { if (listener != null) { // ensure we dispose any previous listeners, dispose should aways be // called on IDisposable objects when we are done with it to avoid leaks listener.Dispose(); } listener = XDListener.CreateListener(mode); // attach the message handler listener.MessageReceived += OnMessageReceived; listener.RegisterChannel(CHANNEL_NAME); // create an instance of IXDBroadcast using the given mode, // note IXDBroadcast does not implement IDisposable broadcast = XDBroadcast.CreateBroadcast(mode, false); }
/// <summary> /// Initialize the broadcast and listener mode. /// </summary> /// <param name="mode">The new mode.</param> private void InitializeMode(XDTransportMode mode) { if (listener != null) { // ensure we dispose any previous listeners, dispose should aways be // called on IDisposable objects when we are done with it to avoid leaks listener.Dispose(); } // creates an instance of the IXDListener object using the given implementation listener = XDListener.CreateListener(mode); // attach the message handler listener.MessageReceived += new XDListener.XDMessageHandler(OnMessageReceived); // register the channels we want to listen on if (statusCheckBox.Checked) { listener.RegisterChannel("Status"); } // register if checkbox is checked if (channel1Check.Checked) { listener.RegisterChannel("Channel1"); } // register if checkbox is checked if (channel2Check.Checked) { listener.RegisterChannel("Channel2"); } // if we already have a broadcast instance if (broadcast != null) { broadcast.SendToChannel("Status", string.Format("{0} is changing mode to {1}", this.Handle, mode)); } // create an instance of IXDBroadcast using the given mode, // note IXDBroadcast does not implement IDisposable broadcast = XDBroadcast.CreateBroadcast(mode, propagateCheck.Checked); }
//-------------------------- form ---------------------------// void FrmMainLoad(object sender, EventArgs e) { Debug.WriteLine("Main start: "); listener = new XDListener(); listener.MessageReceived += new XDListener.XDMessageHandler(listener_MessageReceived); listener.RegisterChannel("NVMessage"); bool kShift = (Control.ModifierKeys == Keys.Shift); bool created; s_event = new EventWaitHandle(false, EventResetMode.ManualReset, "Next-View", out created); // instead of mutex if (created || kShift) // 1st instance or shift key { if (Properties.Settings.Default.UpgradeRequired) { Settings.Default.Upgrade(); Settings.Default.UpgradeRequired = false; Settings.Default.Save( ); } int wX; int wY; int wW = Settings.Default.MainW; int wH = Settings.Default.MainH; Multi.MainLoad(out wX, out wY); //Debug.WriteLine("open main 1 y: {0} ", wY); bool visible; // menu bar visible Rectangle screenRectangle = RectangleToScreen(this.ClientRectangle); int titleHeight = screenRectangle.Top - this.Top; Multi.FormShowVisible(out visible, ref wX, ref wY, wW, titleHeight); if (!visible) { this.Left = wX; this.Top = wY; //Debug.WriteLine("open main 2 y: {0} ", wY); } else { Multi.FormShowVisible(out visible, ref wX, ref wY, wW, wH); this.Left = wX; this.Top = wY; //Debug.WriteLine("open main 3 y: {0} ", wY); } this.Width = wW; this.Height = wH; string curDir = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location); string moPath = curDir + @"\language\"; string cultureStr = Settings.Default.Language; if (cultureStr == "") { cultureStr = CultureInfo.InstalledUICulture.ToString(); Settings.Default.Language = cultureStr; } //Debug.WriteLine("Culture: " + cultureStr); T.SetCatalog(moPath, cultureStr); TranslateMainForm(); tbNoGif(); string recentPath = Settings.Default.RecentImgs; this.recentItem1.LoadList(recentPath); this.recentItem1.UpdateList(); this.recentItem1.MaxItems = 5; this.recentItem1.ItemClick += new System.EventHandler(recentItem_Click); this.recentItem1.UpdateList(); //Debug.WriteLine("open main y: {0} ", Settings.Default.MainY); } else // 2nd instance, give image path to 1st instance and end this 2nd { string[] args = Environment.GetCommandLineArgs(); string commandLine = "S"; if (args.Length > 1) { commandLine = args[1]; } //Debug.WriteLine("send message:"); XDBroadcast.SendToChannel("NVMessage", commandLine); // receive: listener_MessageReceived // send is to itself as well, before exit // NvSendMsg(); does not work for strings, ExitApp(); } }
public IXDBroadcast CreateBroadcast() { return(XDBroadcast.CreateBroadcast(Mode, Propagate)); }