473,385 Members | 2,274 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,385 software developers and data experts.

Delegation and refreshing UI control

VM
How can I display the contents of a datatable in a windows datagrid while
the table is being filled? Here's my summarized code:

delegate void loadAuditFileToTableDelegate();
private void btn_run_Click(object sender, System.EventArgs e)
{
/* In Window form */
loadAuditFileToTableDelegate LoadAuditFileToTable = new
loadAuditFileToTableDelegate(loadAuditFileToTable) ;
LoadAuditFileToTable.BeginInvoke (null, null);
}
private void loadAuditFileToTable()
{
/* Also in Window form */
ZMMatch.Audit zmAudit = new ZMMatch.Audit();
table_auditAddress = zmAudit.OpenAuditAZMFileToView(_SFileName); //
process that takes 2-3 mins. to run
// datagrid.DataSource = table_auditAddress; //this line doesn't seem to
work during a delegate call
}

public DataTable OpenAuditAZMFileToView(string sFileName)
{
/* ZMMatch class
// open file, create table/columns,etc...
sAuditRecord = sr.ReadLine();
while (sAuditRecord != null)
{
/* Parse/process line, fill row, and add row to table. Loop will run
about 500,000 times by adding 500,000 rows */
sAuditRecord = sr.ReadLine();
}
return myTable;
}
Nov 16 '05 #1
2 1343
The data needs to be marshalled back to control by *another* callback and
the Control.Invoke method.

LoadAuditFileToTable.BeginInvoke (new AsyncCallback(yourCallback) , null,
null); //use a callback function

void yourCallback(IAsyncResult iar)
{
if (iar.IsCompleted)
{
dataGrid1.Invoke (new GUIUPdate(guiUpdateMethod),null);

}
}

void guiUpdateMethod()
{

dataGrid.DataSource = theData;

}

This code will correctly load the datagrid when LoadAuditFileToTable is
finished. If you want continuous updating,
you should pass a callback to LoadAuditFileToTable() that will be called
every X records, that will then
invoke the datagrid update.

good luck,
kevin aubuchon

"VM" <vo******@yahoo.com> wrote in message
news:eh**************@TK2MSFTNGP12.phx.gbl...
How can I display the contents of a datatable in a windows datagrid while
the table is being filled? Here's my summarized code:

delegate void loadAuditFileToTableDelegate();
private void btn_run_Click(object sender, System.EventArgs e)
{
/* In Window form */
loadAuditFileToTableDelegate LoadAuditFileToTable = new
loadAuditFileToTableDelegate(loadAuditFileToTable) ;
LoadAuditFileToTable.BeginInvoke (null, null);
}
private void loadAuditFileToTable()
{
/* Also in Window form */
ZMMatch.Audit zmAudit = new ZMMatch.Audit();
table_auditAddress = zmAudit.OpenAuditAZMFileToView(_SFileName); //
process that takes 2-3 mins. to run
// datagrid.DataSource = table_auditAddress; //this line doesn't seem to work during a delegate call
}

public DataTable OpenAuditAZMFileToView(string sFileName)
{
/* ZMMatch class
// open file, create table/columns,etc...
sAuditRecord = sr.ReadLine();
while (sAuditRecord != null)
{
/* Parse/process line, fill row, and add row to table. Loop will run about 500,000 times by adding 500,000 rows */
sAuditRecord = sr.ReadLine();
}
return myTable;
}

Nov 16 '05 #2
VM
Thanks for the post. It worked.

You also mentioned that if I pass a callback to LoadAuditFileToTable() every
X records, it could be updated continuously. Where would I put that
callback? Also, the BeginInvoke from the code you wrote takes 3 parms while
mine only takes two parms (LoadAuditFileToTable.BeginInvoke (new
AsyncCallback(yourCallback) , null). Wast that a typo or are they different
methods?
LoadAuditFileToTable.BeginInvoke (new AsyncCallback(yourCallback) , null,
null);
void yourCallback(IAsyncResult iar)
{
if (iar.IsCompleted)
{
dataGrid1.Invoke (new GUIUPdate(guiUpdateMethod),null);
}
}
void guiUpdateMethod()
{
dataGrid.DataSource = theData;
}
"Kevin Aubuchon" <ke************@sbcglobal.net> wrote in message
news:_W******************@newssvr24.news.prodigy.c om...
The data needs to be marshalled back to control by *another* callback and
the Control.Invoke method.

LoadAuditFileToTable.BeginInvoke (new AsyncCallback(yourCallback) , null,
null); //use a callback function

void yourCallback(IAsyncResult iar)
{
if (iar.IsCompleted)
{
dataGrid1.Invoke (new GUIUPdate(guiUpdateMethod),null);

}
}

void guiUpdateMethod()
{

dataGrid.DataSource = theData;

}

This code will correctly load the datagrid when LoadAuditFileToTable is
finished. If you want continuous updating,
you should pass a callback to LoadAuditFileToTable() that will be called
every X records, that will then
invoke the datagrid update.

good luck,
kevin aubuchon

"VM" <vo******@yahoo.com> wrote in message
news:eh**************@TK2MSFTNGP12.phx.gbl...
How can I display the contents of a datatable in a windows datagrid while the table is being filled? Here's my summarized code:

delegate void loadAuditFileToTableDelegate();
private void btn_run_Click(object sender, System.EventArgs e)
{
/* In Window form */
loadAuditFileToTableDelegate LoadAuditFileToTable = new
loadAuditFileToTableDelegate(loadAuditFileToTable) ;
LoadAuditFileToTable.BeginInvoke (null, null);
}
private void loadAuditFileToTable()
{
/* Also in Window form */
ZMMatch.Audit zmAudit = new ZMMatch.Audit();
table_auditAddress = zmAudit.OpenAuditAZMFileToView(_SFileName); //
process that takes 2-3 mins. to run
// datagrid.DataSource = table_auditAddress; //this line doesn't
seem to
work during a delegate call
}

public DataTable OpenAuditAZMFileToView(string sFileName)
{
/* ZMMatch class
// open file, create table/columns,etc...
sAuditRecord = sr.ReadLine();
while (sAuditRecord != null)
{
/* Parse/process line, fill row, and add row to table. Loop will

run
about 500,000 times by adding 500,000 rows */
sAuditRecord = sr.ReadLine();
}
return myTable;
}


Nov 16 '05 #3

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

Similar topics

1
by: Robert Dick | last post by:
Derived classes sometimes need to delegate portions of the work in overridden methods to methods in their base classes. This was traditionally done with explicit calls in python, e.g., class...
3
by: Jacob | last post by:
Hello All, I am trying to serve out some content via IIS that is hosted on a remote fileserver, and am unable to get the delegation working correctly. Our setup is as follows: Local LAN...
3
by: Tony Johansson | last post by:
Hello! What does it mean with delegation and can you give me one example. //Tony
5
by: Jensen Bredal | last post by:
Hello, I need to display self refreshing information on a web page written with asp.net. I would image that the info would be displayed either as part of a user control or a web control. How can...
2
by: russell.lane | last post by:
I'm building out a pretty standard n-tier web application. The stack includes application/presentation, biz logic, and data access layers on top of an SQL server back end. We want to use...
6
by: Marc Castrechini | last post by:
This is a classic double hop delegation issue, however its the first time we are setting this up so we are doing something incorrectly. If we run through the IDE or using a localhost path on the...
0
by: kkos | last post by:
I noticed the following issue posted as a double-hop issue in many discussion boards but found no answers that explain how to pass the second hop with windows auth from IIS ASPX page to remote SQL...
9
by: Bali | last post by:
Default.aspx is the starting page containing a control(ascx) which has asp:button control on it. On the button click event it has to open a new page as a modal control. Since refreshing a page in a...
0
by: Bali | last post by:
Default.aspx is the starting page containing a control(ascx) which has asp:button control on it. On the button click event it has to open a new page as a modal control. Since refreshing a page in...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?
1
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...
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...
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
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...

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.