On 6 Mar, 23:21, "Willy Denoyette [MVP]" <willy.denoye...@telenet.be>
wrote:
"Cliff" <J...@ballsdeep.netwrote in message
news:11**********************@t69g2000cwt.googlegr oups.com...
On 6 Mar, 19:28, Jon Skeet [C# MVP] <s...@pobox.comwrote:
>Cliff<J...@ballsdeep.netwrote:
<snip>
About thread.join, How does that work when I'm waiting for multiple
threads to finish?
is this what you mean?
foreach (Thread th in arr)
th.Join;
Yup.
as effectivly I need to join all the threads, but execution stops as
soon as you execute that command.
Execution stops on the main thread, yes - but seeing as the whole point
is to wait until all the other threads have finished, it's doing
*exactly* what you want it to.
--
Jon Skeet - <s...@pobox.com>http://www.pobox.com/~skeet
Blog:http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
The part that introduces latency is
if (data.GetType() == typeof(ASAVPN))
dt = ((ASAVPN)(data)).SessionTable;
else
dt = ((VPN3000)(data)).SessionTable;
Getting the session table requires round trips, and waits for data and
subsequent requests etc..
I guess I'm just astounded that setting up 10 threads takes 2-3
seconds. I remember in C++ (years ago as I've been using C# since it
came out) it would have been almost instant.
Cliff.
Are you talking about the timespan between:
DateTime StartTime = DateTime.Now;
Debug.WriteLine("Starting To Launch Threads");
..
...
TimeSpan ts = DateTime.Now.Subtract(StartTime);
Debug.WriteLine("Launch of Threads " + ts.ToString());
or
DateTime StartTime = DateTime.Now;
Debug.WriteLine("Starting To Launch Threads");
..
...
TimeSpan ts = DateTime.Now.Subtract(StartTime);
Debug.WriteLine("Ending Thread Work " + devicename + "
" + ts.ToString());
Starting 10 threads should normally take much less than a second, all depends what the
threads are doing, and it's not possible to know what's done here at all...
dt = ((ASAVPN)(data)).SessionTable;
else
dt = ((VPN3000)(data)).SessionTable;
but *if* SessionTable is quite processor intensive, then, I'm not surprised it takes 2-3
seconds to start 10 threads.
Willy.- Hide quoted text -
- Show quoted text -
The Session Tables are Calling SNMP Calls in 3rd party DLLs and
waiting for the response. As far as i know, that code requests
something, and synchronsly waits for a response, then requests the
next thing. Each call and response taking 100 - 500 ms resulting in a
few seconds operation. (I know some of them are longer, but the
majority are 2/3 seconds)
Hence I'm trying to remove the Synchronous part, and do things
asynchronously.
That is not a processor intensive task.
I've put this on a faster box now, and it seems to be working
better....
It also seems to work far faster the second time its run. maybe that
could be todo with caching?
Here's the readout from it actually running. I've put spaces and
comments round the important bits
Starting the process.
Starting To Launch Threads
Launching Thread HTCVEDT11
Starting Thread Work: HTCVEDT11
Launching Thread HTCVEDT12
Starting Thread Work: HTCVEDT12
Launching Thread NY3VEDT13
Starting Thread Work: NY3VEDT13
Launching Thread TOKP-VPNRAP01
Ending Thread Work HTCVEDT12
00:00:00.4397272
*One of the first threads ends before the threads have even
finished being setup*
The thread 0x874 has exited with code 0 (0x0).
Ending Thread Work NY3VEDT13 00:00:00.3497830
The thread 0xfb8 has exited with code 0 (0x0).
Starting Thread Work: TOKP-VPNRAP01
Launching Thread STCP-VPNRAP01
Starting Thread Work: STCP-VPNRAP01
Launching Thread DTCVEDTVPN1
Starting Thread Work: DTCVEDTVPN1
Launching Thread STCP-VPNRAP02
Starting Thread Work: STCP-VPNRAP02
Launching Thread DTCVEDTVPN2
Starting Thread Work: DTCVEDTVPN2
Launching Thread GTCVEDTVPN5
Starting Thread Work: GTCVEDTVPN5
Launching Thread GTCVEDTVPN6
Starting Thread Work: GTCVEDTVPN6
Launching Thread STCP-VPNRAP03
Starting Thread Work: STCP-VPNRAP03
Ending Thread Work STCP-VPNRAP02 00:00:00.4697086
The thread 0x338 has exited with code 0 (0x0).
Launching Thread STCP-VPNRAP04
Starting Thread Work: STCP-VPNRAP04
Ending Thread Work STCP-VPNRAP03 00:00:00.2298574
The thread 0xe48 has exited with code 0 (0x0).
Ending Thread Work STCP-VPNRAP04 00:00:00.2198636
The thread 0x180 has exited with code 0 (0x0).
Ending Thread Work GTCVEDTVPN6 00:00:00.7695226
The thread '<No Name>' (0x9d8) has exited with code 0 (0x0).
Launching Thread TOKP-VPNRAP02
Launching the threads took:
00:00:03.1880222
*Only here have all the threads been setup thats 3 seconds
into the task when some of the first threads have already finished.*
Starting Thread Work: TOKP-VPNRAP02
Ending Thread Work STCP-VPNRAP01 00:00:01.3891382
The thread 0xf20 has exited with code 0 (0x0).
Ending Thread Work TOKP-VPNRAP02 00:00:01.3291754
The thread 0xbe0 has exited with code 0 (0x0).
Ending Thread Work GTCVEDTVPN5 00:00:02.6983260
The thread '<No Name>' (0xc94) has exited with code 0 (0x0).
Ending Thread Work HTCVEDT11 00:00:08.9644386
The thread '<No Name>' (0xf24) has exited with code 0 (0x0).
Ending Thread Work DTCVEDTVPN1 00:00:07.8951020
The thread 0xbf0 has exited with code 0 (0x0).
Ending Thread Work TOKP-VPNRAP01 00:00:12.7121136
The thread 0xb70 has exited with code 0 (0x0).
Ending Thread Work DTCVEDTVPN2 00:00:18.3586106
The thread '<No Name>' (0x718) has exited with code 0 (0x0).
The thread 0x13c has exited with code 0 (0x0).
Waiting for the threads finsh 00:00:17.4091996 To Complete their work