Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Asynchronous Webservice call and abort

Asynchronous Webservice call and abort

Scheduled Pinned Locked Moved C#
question
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jens Meyer
    wrote on last edited by
    #1

    Hi, i need to make a call to a webservice and in addition abort this call if the response exeeds some specific time. I want to do this because i have to provide a method to the user which returns a value from a webservice through this method not through some callbackevent. This way i decided that it would be a good way to wrap the call to the service in a method, wait for the response (or a specific time, whatever comes first) and return the value to the user. What i have done so far is that i make a call to XXXAsync, hooked up to the return event and set a flag that the webservice responded. In the method called by the user a wait for this flag to be set to true or a specific time, but somehow the webservice return event never fires. If i remove the waiting loop everything works fine. Here is some sample code of the method i want to wrapt the webservice call in: public float FaceImageQuality(Image faceImage) { this.retrievedFaceQuality = -10; this.faceQualityCheckReturned = false; fvws.FaceQualityAsync(ImageToByteArr(faceImage)); int localCounter = 0; while (localCounter < this.maxWaitTime || this.faceQualityCheckReturned) { localCounter++; Thread.Sleep(100); } if (!this.faceQualityCheckReturned && localCounter >= this.maxWaitTime) throw new Exception(String.Format(this.webServiceDidNotResponded, (this.maxWaitTime * 10), "FaceImageQuality")); return this.retrievedFaceQuality; } private void fvws_FaceQualityCompleted(object sender, FaceValidationClass.FaceValidationWebService.FaceQualityCompletedEventArgs e) { this.retrievedFaceQuality = e.Result; this.faceQualityCheckReturned = true; } When i remove the Thread.Sleep call and the loop off the code the event fires, but only after the method is left. Does anyone knows a way to solve this? Best regards Jens

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups