Add-In run differently from and Window Form debugging

Add-In run differently from and Window Form debugging

Anonymous
Not applicable
311 Views
3 Replies
Message 1 of 4

Add-In run differently from and Window Form debugging

Anonymous
Not applicable

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!

 

0 Likes
312 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable

I just find out something.

I think that the problem is that Add-In run the timer when I press the button1.

If I close, then open the window form and press button1 again, one more timer will be use by inventor.

Now I understand the reason why I cannot dispose the timer.

 

Add-In will run a command from the time it run to the time we turn off Inventor (if we not turn off this command inside this moment)

 

Running command again means that we add one more upper circle activity.

 

If I press dispose timer, this only executes timer.dispose() for the current activity and doesn't affect to the previous command. This is the reason why if I turn off the command and I turn on again, pressing dispose but nothing change.

 

So, could anyone know the solution for this situation??

I want this function run or not run only in single, not in parralel, although we change information from accessing this button many time

 

Something like this:

 

If (Command.Run Is FirstTime) Or (Command.Run Is Nothing)  Then

 

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 = CInt(Val(ComboBox1.Text))

     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

 

 

 

 

 

If (Command.Run Is Not Firsttime) And (PreviousCommand.Run Is Not Nothing) Then

      Set the value from combobox1 to oT and update value oT to Timer1_Tick.............only change value from the first Run.....

      If NotRun_Click Then

                Dispose Timer1

                Release the command.run

 

 

Sorry for my bad programming language......!!!!

Many thanks in advance!

 

 

0 Likes
Message 3 of 4

Anonymous
Not applicable

Do anyone know the solution for this problem?? Is it possible???

0 Likes
Message 4 of 4

Anonymous
Not applicable

Recently, I make a lot of change in my program, the logic is like this:

 

When I click the button1, the values of comboboxs will be write to a database. These values are # 0. This function runs.

If I don't want to use this function, I click the button2. These value will be set to 0. This function will not work anymore.

 

However I still stuck in one thing:

 

In the first time  that I open Inventor  after I install the Add-In (the value is 0 now), I change the value in combox and click button (change to the value # 0). I check the database and it is written, however, nothing happens. I must close Inventor and reopen it again, now I can use this button properly.

 

Everytime, I set the value to 0, I must repeat the upper stuck!

 

If Inventor run when the the value is # 0, this add-in works well.

 

If I create a window form and test this, this work very well .

 

I feel like that something happen inside Inventor Add-Ins, but I don't know the reason why this happen?

I used Event Watcher, but I cannot find out the reason why too.

 

0 Likes