What I need: I have a WPF/Vb.net application and need to delay a section of code from running, otherwise is keeps running.. I'd like to delay this section of code for 3 seconds.

Problem: I am working with a scale and printer and when a weight item is placed on the scale and a button is pushed to auto-print, the printer will keep spitting out paper. But it should only spit out one sheet. The print should only print one sheet. The app is constantly getting data from the scale, so if something is taken off the scale, it won't print anything. But if the item is left on the scale it will continuously printing. So that's why I was think a delay of some sort would work...Because when auto print is set, they are taking items off, paper should print, then item is taken off, and the next time is put on, paper should print and so on and so on,

I tried: System.Threading.Thread.Sleep(ms) - This does not work because this freezes my entire UI.

5 Years
Discussion Span
Last Post by codeorder

That link isn't very helpful. Its about launching and managing apps from VB.. I don't need to do that.


The link takes me to a problem that is similar to mine, But the links supplied in that thread really has nothing to do with "threads".

Edited by iamjess147: n/a


See if this helps.

Public Class Form1
    Private bSendToPrinter As Boolean = False

    Private Sub newScaleItem()
        '// code here to get item when placed on scale.
        '// If Not yourScale.Weight=0.0 Then
        bSendToPrinter = True
        '// End If
    End Sub
    Private Sub printScaledItem()
        If bSendToPrinter Then
            bSendToPrinter = False
            '// Print code here.
        End If
    End Sub
End Class
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.