Delay in VB.net

Using timer to slow down code

Page 1 of 1

4 Replies - 18674 Views - Last Post: 19 February 2009 - 12:07 PM Rate Topic: -----

#1 lildaj  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 13-January 09

Delay in VB.net

Posted 13 January 2009 - 10:25 AM

Hi All,

I am creating a programming that is sending info for one pc to another over RF. The desktop show create a xml file. It writes some of the info but not all. I receive a Target Invocation Exception Error.

I realize I need to slow down the incoming Data. I want to use a timer to slow it down.

Does anyone know how to do this?
Is This A Good Question/Topic? 0
  • +

Replies To: Delay in VB.net

#2 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2263
  • View blog
  • Posts: 9,467
  • Joined: 29-May 08

Re: Delay in VB.net

Posted 13 January 2009 - 12:44 PM

The following code will pause the currently running thread of your application to pause for 1000ms which is 1 second.
   System.Threading.Thread.Sleep(1000)


Was This Post Helpful? 0
  • +
  • -

#3 UnLoCo  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 9
  • Joined: 11-February 09

Re: Delay in VB.net

Posted 19 February 2009 - 11:52 AM

View PostAdamSpeight2008, on 13 Jan, 2009 - 11:44 AM, said:

The following code will pause the currently running thread of your application to pause for 1000ms which is 1 second.
   System.Threading.Thread.Sleep(1000)



hello i tried this but the UI becomes unreponsive i hope i can find something better
thanks anyway :)
Was This Post Helpful? 0
  • +
  • -

#4 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2263
  • View blog
  • Posts: 9,467
  • Joined: 29-May 08

Re: Delay in VB.net

Posted 19 February 2009 - 12:03 PM

In most case thats the UI thread.
So use a separate thread for the calculation part of your program, then use delegates to update the UI.
Was This Post Helpful? 0
  • +
  • -

#5 bflosabre91  Icon User is offline

  • go sabres

Reputation: 105
  • View blog
  • Posts: 1,439
  • Joined: 22-February 08

Re: Delay in VB.net

Posted 19 February 2009 - 12:07 PM

as adam was saying u need to use another thread. so research the backgroundworker and it should get you on the right track. the backgroundworker is an easy way of creating a new thread.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1