CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Nov 2013
    Posts
    3

    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!

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    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 ')
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    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.

  4. #4
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    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

  5. #5
    Join Date
    Nov 2013
    Posts
    3

    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!!!!!

  6. #6
    Join Date
    Nov 2013
    Posts
    3

    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
  •  





Click Here to Expand Forum to Full Width

Featured