Click to See Complete Forum and Search --> : Calling Webservice Method from a timer method


FaisalJ
March 20th, 2003, 06:25 AM
I have created a timer.

TimerCallback timerDelegate = new TimerCallback(MyCallBack);

Timer timer = new Timer(timerDelegate,num,1000, 1000);

Simply call MyCallBack function after every second

Now in MyCallBack I just call the HelloWorld function of a simple webservice and displays that value in a listbox

void Inform(Object state)
{
m_lb.Items.Add(s.HelloWorld());

}

The funny thing is that this works only 19 times ...the string Hello is displayed only 19 times after which is stops....


WHY????????????

pareshgh
March 20th, 2003, 02:49 PM
is the webservice getting stoped ? did you checked that ?

FaisalJ
March 20th, 2003, 10:24 PM
I have put a timeout value for the webservice and a exception is thrown in case the server is down......

But in this case no exception is called.....meaning the webservice is running...

IT JUST DOES'NT MAKES SENSE :rolleyes:

pareshgh
March 21st, 2003, 12:34 PM
do you saw the log which it generated,
create a log,

may be its going in recursion where somethign is going wrong

debug it check it out.

Paresh

FaisalJ
March 23rd, 2003, 10:02 PM
Nope...I don't think thats teh problem.....

Some time back another person posted the same problem

http://www.codeguru.com/forum/showthread.php?s=&threadid=214340&highlight=Timer

No solution here as well.

pareshgh
March 24th, 2003, 12:19 AM
the best option would be to use the Begin<MethodName> method on
the class you are using to call the web service. This will cause the web
service to be called on another thread, and you can give it a delegate that
will be called when the result has been obtained. This should keep your app
responsive. Just remember that when the method is called through the
delegate, that it might be (I would think most likely) called on another
thread other than the UI thread, so you should take that into account if
your callback function makes calls to the UI (like to a Refresh method).



-Paresh

FaisalJ
March 27th, 2003, 10:04 PM
Instead of using System.Threading.Timer timer mathod I used

System.Timers.Timer timer method.

Its working like its suppose to. :D

pareshgh
March 28th, 2003, 03:50 PM
din't though life would be so easy
with .NET ;)
:D :D :D