private void Start(object sender, EventArgs eventArgs) { Task.Factory.StartNew(Dequeue); timer = new System.Timers.Timer(1000); timer.Elapsed += timer_Elapsed; timer.Start(); var service = "7500"; var network = ";239.255.0.1"; var daemon = "tcp:7500"; var subject = "TEST.Perf"; receivedMessages = 0; log.InfoFormat("Connecting to TIBCO. Daemon: {0} service: {1}, network: {2}, subject {3}", daemon, service, network, subject); try { Environment.Open(); this.transport = new NetTransport(service, network, daemon); this.listener = new Listener(Queue.Default, OnMessageReceived, transport, subject, null); this.dispacher = new Dispatcher(listener.Queue); log.Info("Connected to TIBCO successfully"); log.Info("Waiting for messages"); dispacher.Join(); } catch (Exception exception) { log.Error("Error connecting to TIBCO", exception); this.Stop(this, EventArgs.Empty); } }
/// <summary> /// 派送Tibco Queue的執行緒 /// </summary> /// <param name="status"></param> private void QueueDispatch(object status) { tbDispatcher = new Dispatcher(tbQueue); tbDispatcher.Join(); }