473,378 Members | 1,416 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.

Updating dataset using thread ... CPU taking lot of time..Need Help

Hello all,

I have a third praty grid control...named C1grid. Im using it in one of
my apps..
Now, I have bind this grid to a custom dataset class named
"DataViewEx".
The code of the class is below...

Now what happens is that im updating this dataviewex class from a
separate thread.....
And then the grid is updated using invoke method.

But here comes the problem....
This app is real time...and there is lots of data coming at a very fast
rate....
And when the updation of dataviewex class takes place the cpu takes a
lot of time.....
And in certain cases it even hangs.....taking almost 100 CPU time...

So my question is that

1) Is it happening because of invoke...Or what is the problem....Why is
the CPU hanigng...
Whats causing the CPU to take such a long time.....

Please any suggestions....

Thanks,
Cheers..

Bye.

The code of the class is below....

using System;
using System.Data;
using System.ComponentModel;

namespace AAA
{
public class DataViewEx : DataView
{
private C1FlexGrid m_fgrdDataGrid;

public DataViewEx(C1FlexGrid fgrdDataGrid) : base()
{
m_fgrdDataGrid = fgrdDataGrid;
}

private delegate void OnListChangedDelegate(ListChangedEventArgs e);

protected override void OnListChanged(ListChangedEventArgs e)
{
if ( m_fgrdDataGrid != null && m_fgrdDataGrid.InvokeRequired )
{
m_fgrdDataGrid.Invoke( new OnListChangedDelegate( OnListChanged ),
new object[]{e} );
}
else
base.OnListChanged(e);
}

private delegate void IndexListChangedDelegate(object sender,
ListChangedEventArgs e);

protected override void IndexListChanged(object sender,
ListChangedEventArgs e)
{
if ( m_fgrdDataGrid != null && m_fgrdDataGrid.InvokeRequired )
{
m_fgrdDataGrid.Invoke( new IndexListChangedDelegate(
IndexListChanged ), new object[]{ sender, e } );
}
else
base.IndexListChanged( sender, e );
}
}
}

Jul 6 '06 #1
1 1941
Hi,

You could try replacing "Invoke" with "BeginInvoke".

BeginInvoke is usually better, because it allows the backgroundthread to
continue its work instead of waiting for the UI thread to perform the update.

There is lots of data coming very fast, is that continuously, or now and then?
If is it continuously, then maybe it would be better to just update the
screen every 200 milliseconds, or faster or slower (I don't know the
requirements).

If it is not continuously, you could refdresh the screen with a small delay,
thus resulting in fewer updates of the screen. I'll explain this a little
better:
If let's say every 5 seconds you have 20 parts of new data with 20 ms
interval, then 5 seconds "silence", and again multiple updates. If, instead
of updating the screen every time new data arrives, you start a timer
(interval 100 ms, for example), and when the timer elapses, then start the
update. This could result in fewer updates, every time showing multiple
parts of your new data.

These are techniques I have used in the past to improve the user experience
when fast screen updates where causing performance problems.

Hope this helps,

Joris
"batista" wrote:
Hello all,

I have a third praty grid control...named C1grid. Im using it in one of
my apps..
Now, I have bind this grid to a custom dataset class named
"DataViewEx".
The code of the class is below...

Now what happens is that im updating this dataviewex class from a
separate thread.....
And then the grid is updated using invoke method.

But here comes the problem....
This app is real time...and there is lots of data coming at a very fast
rate....
And when the updation of dataviewex class takes place the cpu takes a
lot of time.....
And in certain cases it even hangs.....taking almost 100 CPU time...

So my question is that

1) Is it happening because of invoke...Or what is the problem....Why is
the CPU hanigng...
Whats causing the CPU to take such a long time.....

Please any suggestions....

Thanks,
Cheers..

Bye.

The code of the class is below....

using System;
using System.Data;
using System.ComponentModel;

namespace AAA
{
public class DataViewEx : DataView
{
private C1FlexGrid m_fgrdDataGrid;

public DataViewEx(C1FlexGrid fgrdDataGrid) : base()
{
m_fgrdDataGrid = fgrdDataGrid;
}

private delegate void OnListChangedDelegate(ListChangedEventArgs e);

protected override void OnListChanged(ListChangedEventArgs e)
{
if ( m_fgrdDataGrid != null && m_fgrdDataGrid.InvokeRequired )
{
m_fgrdDataGrid.Invoke( new OnListChangedDelegate( OnListChanged ),
new object[]{e} );
}
else
base.OnListChanged(e);
}

private delegate void IndexListChangedDelegate(object sender,
ListChangedEventArgs e);

protected override void IndexListChanged(object sender,
ListChangedEventArgs e)
{
if ( m_fgrdDataGrid != null && m_fgrdDataGrid.InvokeRequired )
{
m_fgrdDataGrid.Invoke( new IndexListChangedDelegate(
IndexListChanged ), new object[]{ sender, e } );
}
else
base.IndexListChanged( sender, e );
}
}
}

Jul 6 '06 #2

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

Similar topics

2
by: Hal Vaughan | last post by:
First, I am aware of both SwingUtilities.invokeLater(), and of using Thread to create a new thread.Thesearepartoftheproblem. I want to have something running in the background, while the...
2
by: Irvin | last post by:
I new to ASP.net and am using the following code to attempt to update an Access 2000 mdb. The code does make it through the code following "try". NO rows are updated. There is a row with the...
5
by: junglist | last post by:
Hi guys, I've been trying to implement an editable datagrid and i have been succesful up to the point where i can update my datagrid row by row. However what used to happen was that once i updated...
7
by: MgGuigg | last post by:
Hello all, This is my first time posting a question to this forum, so here is hoping I am following protocol. I am scraping the rust off my old Basic programming skills, and have just recently...
22
by: Arne | last post by:
How do I pass a dataset to a webservices? I need to submit a shoppingcart from a pocket PC to a webservice. What is the right datatype? II have tried dataset as a datatype, but I can't get it to...
7
by: Gary Paris | last post by:
I am pretty new at .NET and am reading a book on ADO.NET but I need some help. I have the following code in the Load routine of a sample program. I would like to read in some data and take the...
4
by: Geoff | last post by:
Hi I'm hoping somebody can help me with the following problem that has occurred to me. Suppose I have two tables in an SQL Server database. Let's call these tables A and B. Assume that A has...
1
by: FishingScout | last post by:
Thanks for taking a look at this problem for me. I am developing an applicaiton in VB.NET 2005 I have a legacy dll that performs a callback to my windows application. The callback works great...
1
by: Neil Chambers | last post by:
This is more likely a question for an SQL group but as I'm using powershell and dotnet it may be relevant Overview: I'm trying to pull data from Excel into a DataSet - modifying the DataSet -...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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 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.