Click here to Skip to main content
15,892,537 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hey guys,
still on my project ;-(
aniway, for this question i have 2 forms: 'A' will be the main and 'B' the secondary.
A is sending countDown (for e.g: 15:00 minuts) to B, B is shown and the timer in B start runing backwards.
assuming i need to pause (or stop) the timer without killing B, i suppouse to do like this:
dim frmB as new B
frmB.Timer1.Enabled = False.
well... it dosent work!
important: i need to stop the timer inside a function in A.
the function loop on numbers and send sms. when i hit the send button on the second time, the send pause but the timer dosent. the send is from A form, the timer is in B on purpose from several reasons.
now, i tried byVal, byRef, public function and so on...
i guess It is not my specialty :-(
any advice?
thanks,
oron.
Posted
Comments
Andy Lanng 27-May-15 4:24am    
hmm. I am surprised that A can't affect B's timer.

How about creating a public method in 'B' that 'A' can call (call it StopTimer for eg). That method in 'B' stops disables the timer. 'A' calls that method in the instance of 'B'.
oronsultan 27-May-15 4:39am    
i tried that to. it want work.
but maybe this information will help:
on the first click on btnSend, the timer start running and the messages start to send one by one. on the second click, the timer still runing but the messages stop. i did what you said. the StopTimer function entered and set the timer to enabled = false but after the function end, the debugger goes to the timer_tick again and in the immidiate window, the timer is set to enabled = true.
its seems like any changes on B form dont catch. even if i put simple label on B form and change his text, it want change during runtime.

In this Code-Line :
VB
dim frmB as new B
 frmB.Timer1.Enabled = False
... you create a NEW Instance from Form B and try to work with it.
I think it will be better, you do it like this :
VB
dim frmB as Form = B
frmB.Timer1.Enabled = False
 
Share this answer
 
Comments
oronsultan 27-May-15 6:42am    
dear ralf,
after writing this line:
Dim frm As Form = B
the error i get is this:
B is a type and cannot be used as an expression.
i read that the problem could be in the queue of the timer. the timer rise and hase certain amount of queue he have to do. let me remind you that any changes on B form can't be done, not just the timer.
Got it!
in the global variables create delegate and reference for form B as follow:

VB
Private Delegate Sub del()
Dim slice_SendingStat As B = New B()


creating a function in A as follow:

VB
Private Sub PauseTimer()
    slice_SendingStat.TimerEffects.Enabled = False
End Sub


in the btnSend_click function, put this:
Me.Invoke(New del(AddressOf PauseTimer))

that will get access to the form B delegate and pause the timer!!!
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900