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. Return multiple asynch calls synchronously?

Return multiple asynch calls synchronously?

Scheduled Pinned Locked Moved C#
csharpperformancehelptutorialquestion
2 Posts 2 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.
  • M Offline
    M Offline
    matsnas
    wrote on last edited by
    #1

    Hi! I want to to fire a number of asynch method calls from a main thread and have the main thread return true synchronously if the method calls all return true, otherwise false. The asynch method calls should have a timeout which makes them return false. How to best implement in .NET 2.0? Performance is an issue! Pseudo code: public void main() {  SynchObj sObj = new SynchObj();  bool allTrue = sObj.SynchCall(); } public class SynchObj {  public bool SynchCall()  {   bool allTrue = false;   // Create X objects with 3sek timeout   // Fire Asynch calls   // Suspend main thread until all X objects   // ...have returned or timed out   // Resume thread and set allTrue = true if all   return allTrue;  } } public class AsynchObj {  public bool AsynchCall(int timeout)  {   // Make calculation   // Return true or false (if timeout, return false)  } }

    N 1 Reply Last reply
    0
    • M matsnas

      Hi! I want to to fire a number of asynch method calls from a main thread and have the main thread return true synchronously if the method calls all return true, otherwise false. The asynch method calls should have a timeout which makes them return false. How to best implement in .NET 2.0? Performance is an issue! Pseudo code: public void main() {  SynchObj sObj = new SynchObj();  bool allTrue = sObj.SynchCall(); } public class SynchObj {  public bool SynchCall()  {   bool allTrue = false;   // Create X objects with 3sek timeout   // Fire Asynch calls   // Suspend main thread until all X objects   // ...have returned or timed out   // Resume thread and set allTrue = true if all   return allTrue;  } } public class AsynchObj {  public bool AsynchCall(int timeout)  {   // Make calculation   // Return true or false (if timeout, return false)  } }

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      Have you looked at WaitHandle.WaitAll ?


      only two letters away from being an asset

      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