473,378 Members | 1,396 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,378 software developers and data experts.

Threading...

VJ
The below 2 func is in my Main Form..

public static void Main() {

object Arr;

ThreadPool.QueueUserWorkItem(new WaitCallback(GetLatestRptData),Arr);
}
private void GetLatestRptData(object Arr1)
{

'Check update Report XML file (data1.xml).. in a location
}
After the main Form loads I display a summary page. Then the user has a
button on the summary which they can click to go to the detail page. When
the Detail Page loads it will read data1.xml. If the thread has not
completed on the main Form load & is still updating the data1.xml, I would
want to wait for the Detail page to wait & then read the data1.xml. How do I
accomplish this? Can somebody give me a skeleton of Functions that indicates
the communcication. I know i need to use AutoResetEvent, but sure of how to
place the functions
Thanks
Nov 17 '05 #1
1 1196
You can use a delegates "implied" BeginInvoke method, which will run an asyncronous process on a thread-pooled thread:

private delegate void RtpDataInvoker(object Arr1);

public static void Main()
{
RtpDataInvoker invoker = new GetLatestRtpData(dsa);
IAsyncResult result = invoker.BeginInvoke(Arr, null, null);

try
{
// Todo: async process here

// If you need to call a method that has to wait for the process to complete, just pass "result" to the method and
// use the following code:

if (!result.IsCompleted && !result.AsyncWaitHandle.WaitOne(10000, false))
// If the async process is not completed, wait 10 seconds
{
// Todo: timeout expired
}
}
finally
{
invoker.EndInvoke(result);
}
}
--
Dave Sexton
dave@www..jwaonline..com
-----------------------------------------------------------------------
"VJ" <vi********@yahoo.com> wrote in message news:eu**************@TK2MSFTNGP14.phx.gbl...
The below 2 func is in my Main Form..

public static void Main() {

object Arr;

ThreadPool.QueueUserWorkItem(new WaitCallback(GetLatestRptData),Arr);
}
private void GetLatestRptData(object Arr1)
{

'Check update Report XML file (data1.xml).. in a location
}
After the main Form loads I display a summary page. Then the user has a button on the summary which they can click to go to the
detail page. When the Detail Page loads it will read data1.xml. If the thread has not completed on the main Form load & is still
updating the data1.xml, I would want to wait for the Detail page to wait & then read the data1.xml. How do I accomplish this? Can
somebody give me a skeleton of Functions that indicates the communcication. I know i need to use AutoResetEvent, but sure of how
to place the functions
Thanks

Nov 17 '05 #2

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

Similar topics

65
by: Anthony_Barker | last post by:
I have been reading a book about the evolution of the Basic programming language. The author states that Basic - particularly Microsoft's version is full of compromises which crept in along the...
2
by: Egor Bolonev | last post by:
hi all my program terminates with error i dont know why it tells 'TypeError: run() takes exactly 1 argument (10 given)' =program==================== import os, os.path, threading, sys def...
77
by: Jon Skeet [C# MVP] | last post by:
Please excuse the cross-post - I'm pretty sure I've had interest in the article on all the groups this is posted to. I've finally managed to finish my article on multi-threading - at least for...
6
by: CK | last post by:
I have the following code in a windows service, when I start the windows service process1 and process2 work fine , but final process (3) doesnt get called. i stop and restart the windows service...
2
by: Vjay77 | last post by:
In this code: Private Sub downloadBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) If Not (Me.downloadUrlTextBox.Text = "") Then Me.outputGroupBox.Enabled = True...
11
by: Paul Sijben | last post by:
I am stumped by the following problem. I have a large multi-threaded server accepting communications on one UDP port (chosen for its supposed speed). I have been profiling the code and found...
17
by: OlafMeding | last post by:
Below are 2 files that isolate the problem. Note, both programs hang (stop responding) with hyper-threading turned on (a BIOS setting), but work as expected with hyper-threading turned off. ...
0
by: kingcrowbar.list | last post by:
Hello Everyone I have been playing a little with pyGTK and threading to come up with simple alert dialog which plays a sound in the background. The need for threading came when in the first...
7
by: Mike P | last post by:
I am trying to write my first program using threading..basically I am moving messages from an Outlook inbox and want to show the user where the process is up to without having to wait until it has...
126
by: Dann Corbit | last post by:
Rather than create a new way of doing things: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2497.html why not just pick up ACE into the existing standard:...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
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
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
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 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.