473,406 Members | 2,707 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

return value in Thread

How could the return value captured on Thread.
for ex.
Expand|Select|Wrap|Line Numbers
  1. private string Method(int a)
  2. {
  3.    string str = a.ToString();
  4. }
  5.  
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?
Oct 29 '10 #1
2 2495
Use this code

Expand|Select|Wrap|Line Numbers
  1. static string str;
  2. void method(int a)
  3.  
  4. {
  5. str = a.ToString();
  6.  
  7. }
  8.  
  9.  
Nov 1 '10 #2
GaryTexmo
1,501 Expert 1GB
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.
Nov 1 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Chris Gilbert | last post by:
I'm quite stuck with this: I have an import table called ReferenceMatchingImport which contains data that has been sucked from a data submission. The contents of this table have to be imported...
2
by: Tee | last post by:
Hi, Can we use thread.start on a function that has return value? I have a function that will take sometimes to run and it will return a string value, and I want to use thread.start to call...
1
by: Tropos | last post by:
Query: Will a MutexGuard object release before a function return value is copied? Consider the C++ code: class MutexGuard //A familiar sort of class for making mutexes exception-safe { . ....
2
by: Leo Jay | last post by:
Dear all, i would like to get the return value of all threads e.g. def foo(num): if num>10: return 1 elif num>50: return 2
10
by: James Thiele | last post by:
I noticed in PEP 3000 that print will become a function. The PEP references a thread where Guido explains this decision. The thread does not specify what the function will return. Has this been...
7
by: Terry Olsen | last post by:
How do I get this to work? It always returns False, even though I can see "This is True!" in the debug window. Do I have to invoke functions differently than subs? Private Delegate Function...
1
by: Calder Coalson | last post by:
I was searching for ways to get the return value from os.system() calls, when I came across this from 6 years ago. I tried what was suggested in this thread, but output =...
68
by: Jim Langston | last post by:
I remember there was a thread a while back that was talking about using the return value of a function as a reference where I had thought the reference would become invalidated because it was a...
173
by: Marty James | last post by:
Howdy, I was reflecting recently on malloc. Obviously, for tiny allocations like 20 bytes to strcpy a filename or something, there's no point putting in a check on the return value of malloc....
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.