CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Jun 2001
    Location
    Islamabad, Pakistan
    Posts
    113

    Calling Webservice Method from a timer method

    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????????????

  2. #2
    Join Date
    Nov 2002
    Location
    Singapore
    Posts
    1,890
    is the webservice getting stoped ? did you checked that ?
    - Software Architect

  3. #3
    Join Date
    Jun 2001
    Location
    Islamabad, Pakistan
    Posts
    113
    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

  4. #4
    Join Date
    Nov 2002
    Location
    Singapore
    Posts
    1,890
    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
    - Software Architect

  5. #5
    Join Date
    Jun 2001
    Location
    Islamabad, Pakistan
    Posts
    113
    Nope...I don't think thats teh problem.....

    Some time back another person posted the same problem

    http://www.codeguru.com/forum/showth...ighlight=Timer

    No solution here as well.

  6. #6
    Join Date
    Nov 2002
    Location
    Singapore
    Posts
    1,890

    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
    - Software Architect

  7. #7
    Join Date
    Jun 2001
    Location
    Islamabad, Pakistan
    Posts
    113

    Talking A Solution

    Instead of using System.Threading.Timer timer mathod I used

    System.Timers.Timer timer method.

    Its working like its suppose to.

  8. #8
    Join Date
    Nov 2002
    Location
    Singapore
    Posts
    1,890
    din't though life would be so easy
    with .NET
    - Software Architect

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured