CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Mar 2002
    Location
    Holland
    Posts
    279

    Better solution for Click event

    Hi,

    I have the following issue and I was wondering if there is a better solution for it.

    On my window I have a button, after pressing the button the main program starts rs-232 communication. The window is a listerner for a status object that is filled by the class that handles the rs-232. The window does not update until the communication is done. the events are generated, I check. what I think is the problem pressing the button is blocking for the window to update. (cause the events are there).

    My solution: when pressing the button, start a timer(100 mS) and then perform the task. this works fine, but I was wondering if there is a better solution?

    in VB a simple DoEvent would do the trick

    thx for the reaction,

    Jewe
    A VB programmer trying to stay alive in a Real C World

    If the hardware is so great.. why use software to correct it..?? It will only slow it down..
    Al is de hardware nog zo snel de software achterhaalt het wel

  2. #2
    Join Date
    Apr 2003
    Location
    Los Angeles area
    Posts
    776

    Re: Better solution for Click event

    You should do the non-GUI related operation (rs232 connection) in a background thread if it may take more than a second or two.
    "The Chicken and Rice MRE is not a personal lubricant."

  3. #3
    Join Date
    Oct 2003
    Location
    .NET2.0 / VS2005 Developer
    Posts
    7,104

    Re: Better solution for Click event

    Quote Originally Posted by Jewe
    in VB a simple DoEvent would do the trick
    yes, but VB doesnt support the notion of multi-threading without some seriously complicated pitfalls. In java we would give this task to a separate thread, but if you come from a VB background, do read up on multithreading first (to a good extent) because its something you are unlikely to have come across or managed (if your background is purely VB)

    also, note that VB is intended to be a rapid development language, with a lot of convenience features and a great number of inconsistencies. I've seen some very sloppy vb coding which lead me to consider that many VB programmers are quite lazy about the code they write. I dont mean this as a derogation, merely a caution that java requires much more hard work than VB because it isnt so "thrown together with convenience in mind". (Sorry)
    "it's a fax from your dog, Mr Dansworth. It looks like your cat" - Gary Larson...DW1: Data Walkthroughs 1.1...DW2: Data Walkthroughs 2.0...DDS: The DataSet Designer Surface...ANO: ADO.NET2 Orientation...DAN: Deeper ADO.NET...DNU...PQ

  4. #4
    Join Date
    Mar 2002
    Location
    Holland
    Posts
    279

    Re: Better solution for Click event

    Joe Nellis and Cjard thank you both for the reply.

    any good tips of which articals to read?
    I agree with the fact that VB does allow you to program poorly.
    but which programming tools does not?

    That's the reason I posted..

    later,

    Jewe
    A VB programmer trying to stay alive in a Real C World

    If the hardware is so great.. why use software to correct it..?? It will only slow it down..
    Al is de hardware nog zo snel de software achterhaalt het wel

  5. #5
    Join Date
    Apr 2003
    Location
    Los Angeles area
    Posts
    776

    Re: Better solution for Click event

    "The Chicken and Rice MRE is not a personal lubricant."

  6. #6
    Join Date
    Oct 2003
    Location
    .NET2.0 / VS2005 Developer
    Posts
    7,104

    Re: Better solution for Click event

    Quote Originally Posted by Jewe
    Joe Nellis and Cjard thank you both for the reply.

    any good tips of which articals to read?
    I agree with the fact that VB does allow you to program poorly.
    but which programming tools does not?
    oh, of course.. all progrmming languages have scope for making a real dog's dinner of things, but VB more so than most, i see, because of the huge number of conveniences it offers; if you need a variable, you just write the name without needing to declare it. if youre doing string concatenation you can use & or +, but they do behave differently, there are shortcuts for common types, the looping structures have no fine grained control..

    it's very... basic?

    kinda like Mac OS; it doesnt lend itself to power applications, because it doesnt generally have power users. that's not to say that every vb program is noddy art, just that the better examples of poorly structured, ill thought out code, are found in vb
    "it's a fax from your dog, Mr Dansworth. It looks like your cat" - Gary Larson...DW1: Data Walkthroughs 1.1...DW2: Data Walkthroughs 2.0...DDS: The DataSet Designer Surface...ANO: ADO.NET2 Orientation...DAN: Deeper ADO.NET...DNU...PQ

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured