Add-In run differently from and Window Form debugging

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I got a problem and I don't know how to solve it.
I use the Systems.Windows.Forms.Timer to create some execution after a period of time.
This action happen when I press the button 1
Dim oTime As Integer = 0
Dim oSize As Double = 0
Dim MinuteCount As Integer = 0
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
oT = 5
oS= 5
MinuteCount = 0
Timer1.Interval = 60 * 1000
Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
MinuteCount += 1
Dim x As Integer = 0
For x = 1 To 100 Step 1
If MinuteCount = oT * x Then
Dim oMB As Double
oMB = Cdbl(Textbox1.Text)
If oMB >= oS Then
Dim oDialog As New Dialog1
oDialog.ShowDialog()
End If
End If
Next
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Timer1.Enabled = False
Timer1.Dispose()
End Sub
This code works well when I debug directly from VB.Net for the Button2_Click event.
However when I run in Add-In, I cannot disable and dispose the Timer1.
Does anybody know about this? Please show me how to solve this problem!