Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

Having copied a sample of code posted somewhere (here i believe). I am managed to get an icon appear in my status bar for the program i am working on. This works by having a hidden startup form, separate from the main form that the user see's.

 

What i need to do is have a timer running in the background, whilst the icon is minimised.

 

Firstly i tried adding it to the hidden startup form, but as expected, the form wouldnt check the timer, if its hidden.

 

Secondly i tried creating one in code using the code below

       Dim timer1 As New Timer
       timer1.Interval = 5000
       timer1.Enabled = True
       timer1.Start()

and

   Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs)
       MsgBox("in form")
   End Sub

 

But needless to say that didnt work as well.

 

I have lots of process that i want carried out in the background, for this - obviously to start with i am content in getting a timer to show a msgbox every 5 seconds.

 

Could someone please point me in the right direction?

 

Thanks

minimise_troubles.zip

Edited by PlausiblyDamp
  • Administrators
Posted

Have you tried using the timer from system.Threading? The following snippet should give you the idea (just past into a form with a single button)

Private Sub Tick(ByVal state As Object)
       MessageBox.show("test")
   End Sub

   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
       Me.Visible = False
       Dim t As New System.Threading.Timer(AddressOf Tick, Nothing, 0, 5000)

   End Sub

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...