okay so i have this situation:
i have to get round trip time (ping) from a IP, but if i do it in the UI thread it freezes if the ping is high, for example > 300, now to stop the UI to hang i made the ping in another thread, but how can i return value from the 2nd thread(the one pinging)?, i cant directly change the label because this code is in a dll, also even if i use delegates to make new thread (that support return value) the first thread wont stop for 2nd thread to give the return value, if i use thread.join then the whole idea of making ping in 2nd thread is useless because it just joines the 1st thread and freeze it...
any helps?
4 6053
I'm not 100% sure so I'll just throw this out there...
Have your ping thread call the delegate when it's done, then have the main thread, when it receives that call, update the label. The form runs normally.
Nothing should have to wait on anything, it just updates when it gets the call.
Does that make any sense? If you've tried that and it doesn't work, then sorry. I haven't done much work with delegates, but this seems like any other event driven process. The main form should update when it gets the data, but it shouldn't need to wait on it.
as i said, the code is in a DLL, so i just dont have a label here, i dont want the form calling for ping request to freeze
and once again gary, u r the one helping me, suspicious how always u help me.. lol
Suspicious? Nah... maybe I just troll this forum too much ;)
Anyway, are you saying the code to the ping program is in a DLL? If so, you should still be able to create a thread to run the ping process, then call a delegate when it returns.
Can you please provide more details?
well actually nvm it, i spent a hour while i was sleepy cuz i was up all night and wrote this code, works exactly as i want, it may look noobish or ugly cuz i wrote it at 7 AM waking all night... Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
by: Maximus |
last post by:
Hi,
I was just wondering, is it good to use return without arguments in a void
function as following:
void SetMapLayer()
{
if( !Map ) return;
layer = LAYER_MAP;
}
|
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
|
by: Jack Addington |
last post by:
I have a 3rd party object that fires an itemchanged event when someone edits
some data on a form. This event has a custom eventArgs that has a field
called ActionCode. In the code of the event,...
|
by: dcassar |
last post by:
I have had a lively discussion with some coworkers and decided to get
some general feedback on an issue that I could find very little
guidance on. Why is it considered bad practice to define a...
|
by: semedao |
last post by:
Hi , I am using asyc sockets p2p connection between 2 clients.
when I debug step by step the both sides , i'ts work ok.
when I run it , in somepoint (same location in the code)
when I want to...
|
by: chance |
last post by:
I want my thread method to return a String. However, the compiler is
saying that the best overloaded method match for
System.Threading.Thread has some invalid arguments. Not sure what I
need to...
|
by: Chris Roth |
last post by:
I've been working with boost::threads to do some multithreading in my
code and have run into some questions that I haven't been able to find
answers to.
I'll include some sample code to...
|
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...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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...
|
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...
|
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...
|
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,...
|
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...
| |