473,396 Members | 1,599 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Pause not Sleep

Cintury
81
Hi All,

I'm developing a mobile app in VB and I was wondering if there was anyway to pause or wait a thread without putting it to sleep. I'm just trying to maintain a wireless network connection while I check internet connectivity for 30 secs but if I put the thread to sleep the connection itself closes. The current method is
Expand|Select|Wrap|Line Numbers
  1. _sleepTimeBetweenConnectTries = 900 'milliseconds 
  2. System.Threading.Thread.Sleep(_sleepTimeBetweenConnectTries)
  3.  
I'm racking my brain and the sdk to see if there is a wait or pause or delay function but all I can find is sleep and that is not what I want.
Thanks
Mar 11 '08 #1
4 2669
kadghar
1,295 Expert 1GB
Hi All,

I'm developing a mobile app in VB and I was wondering if there was anyway to pause or wait a thread without putting it to sleep. I'm just trying to maintain a wireless network connection while I check internet connectivity for 30 secs but if I put the thread to sleep the connection itself closes. The current method is
Expand|Select|Wrap|Line Numbers
  1. _sleepTimeBetweenConnectTries = 900 'milliseconds 
  2. System.Threading.Thread.Sleep(_sleepTimeBetweenConnectTries)
  3.  
I'm racking my brain and the sdk to see if there is a wait or pause or delay function but all I can find is sleep and that is not what I want.
Thanks
this sub might be of help:

Expand|Select|Wrap|Line Numbers
  1. sub mySleep (Secs as single)
  2. dim t as single
  3. t=timer
  4. do
  5.     doevents
  6. loop until (secs+t) <= timer
  7. end sub
^.^
Mar 11 '08 #2
Cintury
81
this sub might be of help:

Expand|Select|Wrap|Line Numbers
  1. sub mySleep (Secs as single)
  2. dim t as single
  3. t=timer
  4. do
  5.     doevents
  6. loop until (secs+t) <= timer
  7. end sub
^.^
Thanks for the help I think your idea just might work but just a few errors. when I try to use timer I get this error:

'Timer' is ambiguous, imported from the namespaces or types 'System.Threading, System.Windows.Forms'.
Mar 12 '08 #3
kadghar
1,295 Expert 1GB
Thanks for the help I think your idea just might work but just a few errors. when I try to use timer I get this error:

'Timer' is ambiguous, imported from the namespaces or types 'System.Threading, System.Windows.Forms'.
Thats a problem, i suppose because of the Mobile system.

Timer will get the seconds that have passed this day, but any other function that calls the system time will do. I think you'll have to find out which one fits better here. (maybe 'NOW')
Mar 12 '08 #4
Cintury
81
Ok I've got the timer setup and I believe its running. I just need to create a busy (do nothing loop) until the timer hits its designated interval. This is what I have so far. I'm looking to exit the timer once the interval is up and return to the calling method. I just don't know how to compare the time object in the timer. I'm trying to setup a Do Nothing While timer.currenttime < timer.interval loop.

Expand|Select|Wrap|Line Numbers
  1. Private Sub StarthttpTimer(ByVal waitTime As Integer)
  2.  
  3.  
  4.         httpTimer = New System.Windows.Forms.Timer
  5.         httpTimer.Interval = waitTime
  6.         httpTimer.Enabled = True
  7.         onceStarted(httpTimer)
  8.     End Sub
  9.  
  10.     'timer callback
  11.     Private Sub onceStarted(ByVal hTimer As System.Windows.Forms.Timer)
  12.         Do While hTimer (missing the required member call to access its current time)
  13.         Loop
  14.     End Sub
  15.  
Mar 13 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: arajunk | last post by:
I was looking around for some code for a special purpose and found this. Seems it should print "here we go" , pause 5 seconds, print "now we are back". Instead, it pauses 5 seconds before...
19
by: C# Learner | last post by:
What's a nice way to create a non-blocking pause in execution? Will I need to use some kind of timer for this, or is there a nicer way?
8
by: Wim | last post by:
My GUI application starts a process (a console program) when the user hits Play. I would like to add an option to pause that process. The code I've added to detect if the user hit pause/unpause...
2
by: Dave | last post by:
I have a program that I need the program to temporarly stop and wait for a response from a piece of equipment. After a set period I want the program to continue. Like below --execute lline...
11
by: Paul Mars | last post by:
How to pause in the middle of a sub? I can not use a timer. The Sub can not be broken in two. tx, paul
2
by: eSolTec, Inc. 501(c)(3) | last post by:
Thank you in advance for any and all assistance. Is there a way to start, pause and resume a recurrsive search exactly where you left off, say in the registry programmatically? -- Michael Bragg,...
6
by: Peted | last post by:
Hi wondering what is the best way to do this Need a user to click a button, that sends 3 or 4 string based commands via a TCP/ip socket link I can connect to the ip device no problems, am...
0
by: steveyjg | last post by:
I'm trying to call a function that will pause execution for 30 seconds and have a counter timer counting to 30 seconds during this pause. When the counter hits 30 execution of the program will...
19
by: dave.zoltan | last post by:
Hi everybody, I am awfully new to programming in C and all I have had to work with so far have been tutorials that I've found online. In my searching, however, I have not found a solution to a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.