.NET Components for Mobility

multi-threading

Last post 07-05-2007 10:25 AM by matthewwebster. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 07-02-2007 5:06 PM

    multi-threading

    having gotten the basics of a remote control type app working on my Windows Mobile 5 Pocket PC I was hoping to employ some multi-threading to enable things like active slider bars for the "Current Tune Position" etc.

    however, when I created the forms Timer control and started it up the application locked at the point of btListener.Start();

    it appears as though the limit on threads (of a certain type, don't ask me which) is reached when this occurs in the standard app.  i'm assuming this to be two threads max as the app requires these - although one is continuously blocked until receipt of a message.

    it seems sensible that the timer controls can function with multi threads if you assume they all fire from one system thread.  i don't know this for sure, however i did test 3 seperate timer controls working perfectly.  However, when the standard bt app is listening, just starting one more timer control or system thread locks up the application completely.

    am i reading this wrong or is there a way round this?

    matt

    Filed under: , , ,
  • 07-03-2007 1:52 PM In reply to

    Re: multi-threading

    Can you post the code you are using? there shouldn't be an issue with number of threads when spinning up a background thread to listen. You may find some of the sample code helpful to illustrate doing this.

    Peter

    Peter Foot
    Microsoft Device Application Development MVP
    www.peterfoot.net | www.inthehand.com
  • 07-03-2007 5:41 PM In reply to

    Re: multi-threading

    here's the important parts:

    private System.Windows.Forms.Timer timer1;

    private System.Windows.Forms.Timer timer2;

    private System.Windows.Forms.Timer timer3;

    private void Initialise()

    {

    SelectDevice();

    // start listening thread

    t1 = new System.Threading.Thread(new System.Threading.ThreadStart(receiveLoop));

    t1.Start();

    //timer2.Enabled = true;

    //timer1.Enabled = true;

    }

    Taking out the comments from either of the last two lines causes the app to lock up.

     matt

  • 07-04-2007 5:40 PM In reply to

    Re: multi-threading

    That's not really enough to tell what's occuring.  As previously you were getting the exception messages "An error message cannot be displayed because an optional resource assmebly containing it cannot be found", it would seem that you're not running your programs from within the VS debugger, but copying and running them manually?  If so can you hit F5 to run then from within the debugger and see what occurs.

    I wonder whether you're accessing your Form controls from a different thread -- that's not allowed and could cause deadlock/hangs etc.  See the articles listed at http://32feet.net/forums/p/523/1679.aspx#1679 for more.

    Alan J. McFarlane
    http://www.alanjmcf.me.uk/
    Please follow-up in the newsgroup for the benefit of all.
    Have I helped? Consider visiting my Amazon wishlist, see my homepage.
  • 07-05-2007 10:25 AM In reply to

    Re: multi-threading

    Well, here's the full app: http://home.freeuk.com/eudoxus/BtChat.iTunesRemote.2007-07-05.001.rar

    I've modified it a little since the last posts here, but it's basically the same.  The optional resource assembly issue is no more as I'm building as NETCF version 1 now, but the multi-threading is still an issue; Whether I start a Timer control or create another System.Threading.Thread, the application locks up at the point of starting the thread object - even though I've proven that I can have 3 Timer control running at the same time.

    Any help would be greatly appreciated (especially as my work machine now has the damn ABE Controller from Windows Update and BT no longer works here.)

    Matt.

Page 1 of 1 (5 items)
Copyright © 2001-2008 In The Hand Ltd. All rights reserved. Terms of Use and Privacy Policy.