Jump to content

App not freezing while doing something else

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
7 replies to this topic

#1
sakishrist

sakishrist

    Programmer

  • Members
  • PipPipPipPip
  • 109 posts
Hello everyone! I have the following problem, I have to connect to database on a remote server. Thats OK, I did it but my program is freezing for a few seconds until its connected. Is there a way to make my program do something else wile doing something like connecting? another problem is that i can not interrupt the connection process because the the code isn't mine, it's a dll I'm connecting through.
I'm using VB.NET 2008
Thanks :)

#2
Guest_Jordan_*

Guest_Jordan_*
  • Guests
You can try the My.Application.DoEvents() method before and after your connection execution. This may help.

#3
sakishrist

sakishrist

    Programmer

  • Members
  • PipPipPipPip
  • 109 posts
I did that but it does not really help because the function that i call takes more than 15 seconds to complete and until then the app is "Not responding" and the bad thing is i can't change the code of that function as it is in a DLL.
Thanks a lot!

#4
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts
If you could change the code, I'd suggest sprinkling Application.DoEvents() calls throughout the code. The only thing I can suggest is to run the code using a separate thread. That way, the main thread that handles the responsiveness of the UI is unaffected.

However, directly implementing multiple threads is complicated. You might need to do some work :)
Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums

#5
sakishrist

sakishrist

    Programmer

  • Members
  • PipPipPipPip
  • 109 posts
I did try the multiple treads and thats exactly what I was looking for. It wasn't so hard to put the connection code to another thread.
Thanks!

#6
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts
Er, you're welcome - but actually, I've never actually known how to exactly use multiple threads - could you post the code for me?

It's weird, I just gave you the answer, yet I'm asking for it back from you again...
Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums

#7
sakishrist

sakishrist

    Programmer

  • Members
  • PipPipPipPip
  • 109 posts
I will but not right now ... for now I can just give this link because I'm writing from my PPC. Well it's not so difficult to just make a thread but its getting REALLY thought to control them if there are many of them. For example my application uses 3 threads, they all have to be performed in some logical order and sometimes the main application has to wait for 1 or 2 of them to complete so it can continue without errors, to wait for one thread I have to raise an event so when that event is done the app may continue. Now thats the biggest problem I have ... to synchronize them so there are no errors.

#8
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts
Hmm... thanks for the link.
Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums