473,406 Members | 2,549 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,406 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 1943
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.  These are part of the problem. 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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
tracyyun
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...
0
agi2029
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 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.