-
November 26th, 2013, 02:43 PM
#1
VB 2005 - Smart Device: add extra tread to check if network is active
Hello,
I have a smart device app where I would like to have an extra tread running all time to check if the network is connected...(easy ping, reply Y/N)
Any idea how to start this extra tread?
(please supply code with all definitions...as I'm quit a newby...:-()
Thx!
-
November 26th, 2013, 09:45 PM
#2
Re: VB 2005 - Smart Device: add extra tread to check if network is active
not without knowing the specifics, like THE DEVICE, or what the thread does (besides 'ping, reply ')
-
November 27th, 2013, 01:32 AM
#3
Re: VB 2005 - Smart Device: add extra tread to check if network is active
Here's an example that i used to spawn a thread to print a receipt...
Code:
---------
Dim WT1 As New System.Threading.Thread(AddressOf PrintReceipt)
WT1.Start()
---------
Private Sub PrintReceipt()
Dim TmpPrinter As New Printers.PrinterModule("ID1")
Dim nr_of_copies As Integer
AddHandler TmpPrinter.PrintPage, AddressOf PrintPageHandler
For nr_of_copies = 1 To Copies.KeyVal 'get nr. of copies as setup in File/Properties
TmpPrinter.Print()
Next
End Sub
Private Sub PrintPageHandler(ByVal sender As Object, ByVal e As Printing.PrintPageEventArgs)
Dim canvas As Graphics = e.Graphics
Dim receipt As New ReceiptPage(canvas)
receipt.PrintText("TAX INVOICE", ReceiptPage.Location.Center, , , False)
receipt.PrintText("___________", ReceiptPage.Location.Center)
receipt.PrintText("", ReceiptPage.Location.Center)
receipt.PrintText("Vendor ID :", ReceiptPage.Location.Left, , , False)
receipt.PrintText(ThisVendor.VenID, ReceiptPage.Location.Right)
receipt.PrintText("Name :", ReceiptPage.Location.Left, , , False)
receipt.PrintText(ThisVendor.VenName, ReceiptPage.Location.Right)
receipt.PrintText("Address :", ReceiptPage.Location.Left, , , False)
receipt.PrintText(ThisVendor.Addr1, 200, ReceiptPage.Location.Right)
receipt.PrintText(ThisVendor.Addr2, 250, ReceiptPage.Location.Right)
receipt.PrintText("VAT Nr. :", ReceiptPage.Location.Left, , , False)
receipt.PrintText(ThisVendor.Vatno, 200, ReceiptPage.Location.Right)
receipt.PrintText("Invoice Nr. :", ReceiptPage.Location.Left, , , False)
receipt.PrintText(ThisTransHead.Invno, ReceiptPage.Location.Right)
receipt.PrintText("Date :", ReceiptPage.Location.Left, , , False)
receipt.PrintText(Date.Now.Date.ToString, ReceiptPage.Location.Right)
------------
End Sub
As you can see.. you simply tell it on which function/sub to use as a starting point, and start it....
Of course you also have to be sure of thread safe call's.. but as long as you dont try to reference any controls on the form, you should be fine....
Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
WPF Articles : 3D Animation 1 , 2 , 3
Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.
-
November 27th, 2013, 10:45 AM
#4
Re: VB 2005 - Smart Device: add extra tread to check if network is active
To check for network connectivity, you might want to have a look here :
http://www.codeguru.com/columns/vb/d...t-programs.htm
-
November 27th, 2013, 12:49 PM
#5
Re: VB 2005 - Smart Device: add extra tread to check if network is active
Thx for all the info!
But I figured out that it might be better just to use a timer...as I want to check if the network is connected every few seconds...and this seems to work pretty fine!
Anuway, thx for the assist!!!!!
-
November 27th, 2013, 12:50 PM
#6
Re: VB 2005 - Smart Device: add extra tread to check if network is active
GremlinSA,
I'll just copy this :-) as I might integrate this for my printjob.... Thx!!!
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
|