Failed to initiate an advise loop using threads

Aug 6, 2010 at 7:13 AM

Hello,

I was wondering is it possible to create multiple instances of DdeClient using threads. The code below is as shown below. For the first instance, it works, second instance fails.

 

        private void CreateDdeThread(object data)
        {
            Console.WriteLine("CreateDdeThread");
            Spark spark = (Spark)data;
            DdeClient ddeClient = new DdeClient("Spark", spark.GetSymbol() + ".Depth");
            ddeClient.Disconnected += OnDisconnected;
            ddeClient.Connect();
            ddeClient.StartAdvise("BuyCount.BuyVolume.Buy.Sell.SellVolume.SellCount." + spark.GetMarketDepth(), 1, true, 60000);
            ddeClient.Advise += OnAdvise;
            Thread.Sleep(Timeout.Infinite);
        }

 

Aug 9, 2010 at 10:39 AM
Edited Aug 9, 2010 at 10:49 AM

I guess you need to manage opening / closing connecitons and starting / stopping advise loops appropriately. As far as I experienced it is not possible to subscribe to the same event twice without unsubscrbing. Of course this might depend on the DDE server.