return value in Thread

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Praveen Raj V
    New Member
    • Sep 2010
    • 11

    return value in Thread

    How could the return value captured on Thread.
    for ex.
    Code:
    private string Method(int a)
    {
       string str = a.ToString();
    }
    How this method could be run by thread, and the return value captured.
    Is it possible? If not why?
    What is the reason behind it?
  • Subin Ninan
    New Member
    • Sep 2010
    • 91

    #2
    Use this code

    Code:
    static string str;
    void method(int a)
    
    {
    str = a.ToString();
    
    }

    Comment

    • GaryTexmo
      Recognized Expert Top Contributor
      • Jul 2009
      • 1501

      #3
      I'm no expect in threading; however, I'm not sure if a static member is the correct approach here. I think you can set a callback for the thread so that when it finishes, you can do some processing. You might be able to return a value doing that.

      If you do use the above method, you should probably make sure you use locking to prevent contention on the variable.

      Comment

      Working...