473,672 Members | 2,632 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can we use thread.start on function that has return value?

Tee
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 this function and get
the string, is this possible?
Thanks,
Tee
Jul 21 '05 #1
2 1696
I'm afraid you can't, the ThreadStart delegate has return type void.
You can try BeginInvoke(), EndInvoke(), you can get the return value on
calling EndInvoke(). Or you can write to a common location and use your
own signaling mechanism to indicate that the return value is available.
Regards
Senthil

Jul 21 '05 #2
The only way to do this is to create a class that owns and runs the thread.
The class will contain fields or properties that the thread updates and the
calling class will be able to interrogate those fields or properties when
the thread is done. Remember to use mutex to synchronize the access to the
fields within the class so that the thread and the UI thread don't clash.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"Tee" <th*@streamyx.c om> wrote in message
news:u1******** ********@TK2MSF TNGP10.phx.gbl. ..
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 this function and get
the string, is this possible?
Thanks,
Tee

Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3440
by: Jonas | last post by:
Dear members, How can I use a function return value in a regexpr? $tmp=~s/mysearch/myfunction($1)/; sub myfunction { return $v; }
1
2616
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 { . . . ~MutexGuard(); //releases the mutex when the stack pops
4
4285
by: wongjoekmeu | last post by:
Hello All, I know that when you pass an argument to a function (if you want let the function be able to change the value) then you can choose to pass the argument by reference or a pointer to that argument. Now my question is, why would you prefer to let a function return a reference or a pointer ??? Consider the following with operator overloading. I suppose the operator can be seen as a function (right ?)
4
45200
by: bluedolphin | last post by:
This is my first function in Visual and I'm having a simple syntax syntax issue that I'm hoping someone can help correct for me. I have a function Public Function Sub_Agg_Embedded_Catgeories(Pass_Report_Type_Desc As String, other variables, ....) As Integer I call it with the statement intReturn = Sub_Agg_Embedded_Gender(Pass_Report_Type_Desc, other variables)
8
13998
by: Ravindranath Gummadidala | last post by:
Hi All: I am trying to understand the C function call mechanism. Please bear with me as I state what I know: "every invocation of a function causes a frame for that function to be pushed on stack. this contains the arguments this function was called with, address to return to after return from this function (the location in the previous stack frame), location of previous frame on stack (base or start of this frame) and local variables...
7
1716
by: chellappa | last post by:
hi this program return value automatically ... how it is possible ..i am not return any value... but i return correct values i am using Linux -gcc complier please tell me what is this main() { int a,b,c,sum; printf("ENTER ANY THREE NUMBERS :\n"); scanf("%d%d%d",&a,&b,&c);
11
2762
by: randomtalk | last post by:
hi, i have the following recursive function (simplified to demonstrate the problem): >>> def reTest(bool): .... result = .... if not bool: .... reTest(True) .... else: .... print "YAHHH" .... result =
8
2059
by: bdobby | last post by:
Hi. I am relatively new to js, but I did think I was starting to get the hang of it. Then this happened... I have a form with an onsubmit event handler: <form id="uploadForm" method="post" action="..." onSubmit="checkDates()"> The event handler does some minor validation, then returns true or
4
1649
by: pradeep | last post by:
Hello friends ~ We know that a C function will return a 32-bit value from a function in %eax and a 64-bit value in %edx:%eax. But what about larger return types, for example large structs? The only other spare register is %ecx because %ebx needs to be preserved, but that only brings the %possible total up to 96 bits. What happens after that? Thanks for any information!
6
18989
by: kurt.krueckeberg | last post by:
Can someone explain why this line $bool = isset($_POST) && !empty(trim($_POST)); causes the error message "Can't use function return value in write context". trim() returns a string. I test if it is empty. So what is wrong with that?
0
8404
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8931
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8680
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7446
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6238
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4227
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4418
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2819
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1816
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.