cancel
Showing results for 
Search instead for 
Did you mean: 

Problems with the System.Windows.Forms.Timer

Former Member
0 Kudos

Hi All,

Could some one help me please? I'm having a problem using the System.Windows.Forms.Timer inside an ItemEvent, the timer event just doesn't works...give a look in my code:

private System.Windows.Forms.Timer myTimer = new System.Windows.Forms.Timer();

.

.

.

if (pVal.FormUID.Equals("FrmTimer") && pVal.ItemUID.Equals("btnStartTimer") && (pVal.Before_Action.Equals(true)) && (pVal.EventType.Equals(SAPbouiCOM.BoEventTypes.et_CLICK)))

{

myTimer .Interval = 1000;

myTimer .Enabled = true;

myTimer .Tick += new EventHandler(myTimer _Tick);

}

void myTimer _Tick(object sender, EventArgs e)

{

SBO_Application.MessageBox("Timer: " + DateTime.Now, 1, "OK", "", "");

}

does someone have already tried to use the timer inside an itemevent, or could suggest another solution?

thanks a lot...

Accepted Solutions (1)

Accepted Solutions (1)

former_member201110
Active Contributor
0 Kudos

Hi Bruno,

Unfortunately you cannot use a Forms.Timer without using a windows form (ie not a SBO form). Have you looked at the other 2 timer objects in .Net, the System.Timer.Timer and System.Threading.Timer? Here's a link to a web page that goes through the differences between each one:

http://msdn.microsoft.com/msdnmag/issues/04/02/TimersinNET/

Kind Regards,

Owen

Former Member
0 Kudos

Hey Slater, thanks a lot man! i started to use the System.Timer.Timer and it resolved my problems!!!

Thanks a lot man!!

[]'s

former_member185703
Active Contributor
0 Kudos

...but please note that it might be problematic to use timers in conjunction with UI API since you might hit B1 at a time where it won't expect to get commands through UI API:

In some rare cases (but still - that's why I write this reply) UI API accepts commands, but B1 cannot really execute them - i.e. you won't get an error (i.e. usually an exception...), but B1 won't do what you told it to.

I.e. in general the recommdeation would be to try to stay away from timers!

Regards,

Frank

Answers (0)