How to call method from code module periodically?

Ask general questions here.
Swapnil_d13
Posts: 11
Joined: Mon Jan 14, 2013 8:50 pm

How to call method from code module periodically?

Post by Swapnil_d13 » Tue Jan 29, 2013 1:04 pm

Hi,
I want to call some method present in code module(.cs file) periodically...Reply with lines of code.

User avatar
Ciege
Ranorex Guru
Posts: 1335
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: How to call method from code module periodically?

Post by Ciege » Tue Jan 29, 2013 11:37 pm

Not quite sure I understand your question...

Are you using the Ranorex IDE to develop your tests in code?
Are you using A Ranorex Test Suite and want to call code from a user module?
Are you using record/playback and want to add code from a user module?

By periodically, what do you mean? Randomly? At a specific interval of time? When you feel the need to call it?

Please elaborate...
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

Swapnil_d13
Posts: 11
Joined: Mon Jan 14, 2013 8:50 pm

Re: How to call method from code module periodically?

Post by Swapnil_d13 » Wed Jan 30, 2013 6:56 am

Yes..I want to call this method for some interval of time(eg. 1min interval) again and again i.e periodically..
Problem : I want to keep polling at status bar after login successful in our web application. In web application, for some reason exception is thrown and error icon comes at status bar and at this time I want to stop test case.I want to write some generic method in code module so that I can track error by calling this method periodically during live run test case.

User avatar
Ciege
Ranorex Guru
Posts: 1335
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: How to call method from code module periodically?

Post by Ciege » Wed Jan 30, 2013 4:04 pm

That's going to be a little tricky.. You will need to create a second, worker thread whose only purpose is to watch for this error. If the worker thread detects the error then it will need to trigger the main thread to cease testing.

Have a look here to help you get started...
http://www.ranorex.com/blog/handling-di ... up-windows
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

Swapnil_d13
Posts: 11
Joined: Mon Jan 14, 2013 8:50 pm

Re: How to call method from code module periodically?

Post by Swapnil_d13 » Thu Jan 31, 2013 7:11 am

It worked but new problem occurred. To fail test case I had written Environment.Exit(-1) after error match found as written in your solution, test case stopped successfully but after this execution it was not showing ranorex report log at end which usually comes after every test case success or failure. Instead of Environment.Exit(-1), I had tried to throw RanorexException but same problem.