Author Topic: wclClient threading?  (Read 2119 times)

Offline pshaw

  • Newbie
  • *
  • Posts: 15
  • Karma: 0
wclClient threading?
« on: July 21, 2010, 11:15:55 AM »
I have created a user control the contains a wclClient and a chart.  The events are OnConnect, OnDisconnect, and OnData.  There is a Start button that connects to the BT device and sends a "REPORT" command.  The OnData event processes the XML record being sent by the device, charts the data, and then sends another "REPORT" command.  Basically does realtime (or close to it) measurements transmitted by the device.  I placed the user control on a form and call it from a MDI application, basically opens a child form for each BT enabled chart, 1 for each device.  This works fine for 1 device, then slowly opens the second device and reads, then on the third it just hangs.  I am thinking that the main application thread is now overloaded.  So my question is how do I put each of these child forms in it's own thread and is that a good idea?  Are there other options?  I looked at the OppThread example and think I just need to define the function like this:
       private void ThreadProc()
        {
            client = new wcl.wclClient();
            client.OnConnect += new wcl.wclConnectEventHandler(client_OnConnect);
            client.OnDisconnect += new EventHandler(client_OnDisconnect);
            client.OnData += new wcl.wclConnectEventHandler(client_OnData);
             client.Transport = wcl.wclClientTransport.ctBluetooth;
            client.BluetoothParams.Radio = Radio;
            client.BluetoothParams.Address = _address;
            wcl.wclErrors.wclShowError(client.Connect());
            while (!_threadstop)
                Application.DoEvents();
            client.Dispose();
            client = null;
         }

Has anyone done something like this?
Thanks.

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3053
  • Karma: 1000
    • Soft Service Company
Re: wclClient threading?
« Reply #1 on: July 21, 2010, 11:34:35 AM »
Hello,

I do not think it helps you. But if you need threads, take a look on OPPThread demo.

 

Sitemap 1 2 3 4 5 6 7 8 9