|
-
May 1st, 2009, 02:27 PM
#1
Thread Starter
Addicted Member
[RESOLVED] An issue about sleeping delay
Hello,
I am using sleeping delay between in my application - send the first serial packet and then delay a few seconds and then send the 2nd packet. The data to be sent is stored in SequenceBuffer(n1,num). The first string is teh first packet to be sent. The second string is delay value and the 3rd string is the 2nd packet to be sent. So in my code when n1 is 1 (the 2nd string), I delay a few seconds based on the string value in SequenceBuffer(1,num)
I expect after the 1st packet is sent, there is a delay. But the delay occurred before the 1st packet sent and then sent both packets. TO make it simple, I changed to delay 10seconds. Any idea?
Private Sub SendSequenceButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SendSequenceButton.Click
Dim n1, n2 As Byte
Dim DelaySecond As String = ""
If SequenceBuffer(0, 0) = 0 Then 'if theere is at least one sequence active, SequenceBuffer(0, 0) is not 0
MsgBox("No Active Sequence! Please Open Esisting One or Create a New One")
Exit Sub
End If
'send all packets in sequence
For n1 = 0 To 100
If SequenceBuffer(n1, 0) = 0 Then
Exit For
Else 'if valid packet
If n1 = 1 Then
Threading.Thread.Sleep(10000)
Else
SendBuffer(0) = SequenceBuffer(n1, 0) 'format
BytesSent = (SendBuffer(0) >> 4) + 1
For n2 = 3 To BytesSent - 2
SendBuffer(n2) = SequenceBuffer(n1, n2)
Next
SendBuffer(BytesSent - 1) = CalCheckSum(SendBuffer, BytesSent - 2) 'checksum
SendPacket(BytesSent)
End If
End If
Next
End Sub
-
May 1st, 2009, 02:42 PM
#2
Re: An issue about sleeping delay
Put a:
Code:
My.Application.DoEvents()
after the SendPacket() line.
Also, be sure to use the CODE tags to format your posted code.
Looking at your routine, I'd recommend using a Queue to store and send your packets.
-
May 1st, 2009, 02:48 PM
#3
Thread Starter
Addicted Member
Re: An issue about sleeping delay
 Originally Posted by Jenner
Put a:
Code:
My.Application.DoEvents()
after the SendPacket() line.
Also, be sure to use the CODE tags to format your posted code.
Looking at your routine, I'd recommend using a Queue to store and send your packets.
Thanks a lot!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|