Exemplo n.º 1
0
        public void TryConnect(string service, string topic, IDDEConversationListener listener)
        {
            var op = this.dispatcher.BeginInvoke(new Action(delegate()
            {
                if(idInst == 0)
                    listener.OnConnect(null);

                using(var hszService = new DdeStringHandle(idInst, service))
                using(var hszTopic = new DdeStringHandle(idInst, topic))
                {
                    var hConv = DDEML.DdeConnect(idInst, hszService.Handle, hszTopic.Handle, IntPtr.Zero);
                    if(hConv == IntPtr.Zero)
                    {
                        var errno = DDEML.DdeGetLastError(idInst);
                        var error = DDEML.GetErrorString(errno) + " (" + errno.ToString() + ")";
                        Log.Emit("dde-connect-failed", "service", service, "topic", topic, "error", error);
                        listener.OnConnect(null);
                    }
                    else
                    {
                        Log.Emit("dde-connect", "service", service, "topic", topic, "hConv", hConv);
                        var conv = new Conversation(this, service, topic, hConv, listener);
                        this.conversations.Add(hConv, conv);
                        listener.OnConnect(conv);
                    }
                }
            }));
        }
Exemplo n.º 2
0
        public void TryConnect(string service, string topic, IDDEConversationListener listener)
        {
            var op = this.dispatcher.BeginInvoke(new Action(delegate()
            {
                if (idInst == 0)
                {
                    listener.OnConnect(null);
                }

                using (var hszService = new DdeStringHandle(idInst, service))
                    using (var hszTopic = new DdeStringHandle(idInst, topic))
                    {
                        var hConv = DDEML.DdeConnect(idInst, hszService.Handle, hszTopic.Handle, IntPtr.Zero);
                        if (hConv == IntPtr.Zero)
                        {
                            var errno = DDEML.DdeGetLastError(idInst);
                            var error = DDEML.GetErrorString(errno) + " (" + errno.ToString() + ")";
                            Log.Emit("dde-connect-failed", "service", service, "topic", topic, "error", error);
                            listener.OnConnect(null);
                        }
                        else
                        {
                            Log.Emit("dde-connect", "service", service, "topic", topic, "hConv", hConv);
                            var conv = new Conversation(this, service, topic, hConv, listener);
                            this.conversations.Add(hConv, conv);
                            listener.OnConnect(conv);
                        }
                    }
            }));
        }
Exemplo n.º 3
0
            public Conversation(DDEClient client, string service, string topic, IntPtr hConv, IDDEConversationListener listener)
            {
                this.timer = new DispatcherTimer(TimeSpan.FromSeconds(2), DispatcherPriority.Background, this.OnTimer, client.dispatcher);

                this.Client   = client;
                this.Service  = service;
                this.Topic    = topic;
                this.Handle   = hConv;
                this.listener = listener;
            }
Exemplo n.º 4
0
            public Conversation(DDEClient client, string service, string topic, IntPtr hConv, IDDEConversationListener listener)
            {
                this.timer = new DispatcherTimer(TimeSpan.FromSeconds(2), DispatcherPriority.Background, this.OnTimer, client.dispatcher);

                this.Client = client;
                this.Service = service;
                this.Topic = topic;
                this.Handle = hConv;
                this.listener = listener;
            }