473,605 Members | 2,590 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problems with datagrid,datavi ew getting NullReferenceOb ject and SEHException

- R
Hello all.

I'm new to .Net so please help me out.

I have a application with several "Threads" running to observe various
things. From time to time each thread need to add an log entry, which is
displayed on a form (a datagrid on a form)

there is no database, but i created a dataset using the designer. One
Entity/Table is called Log and contains the log-entries.

The main window opens a OberverHandler class, which opens all the observer-
objects, that contains a timer each (a Threading timer)

Each observer got a reference to ObserverHandler . So when a new log need to
be written, a function on the ObserverHandler is called. This function got
a reference to the dataset through the mainwindow, and it adds the row to
the Log table.

The Log form got a dataView and a ddataGrid. The datagrid.dataso urce = the
dataview. The dataview opens and makes a = new DataView
(mainWindow.dat aset.tables["Log"]) - and is running.

The log-form starts to fill up with the log-entrys, but after a short time
the application fails with a NullReferenceOb ject or a SEHException.

I tried many different things, including making a local dataTable on the
Log form and add rows to it. All with the same result. No crashes if the
log window is not opened. After it opens there goes from 30 sec's to
several minutes before it crashed.

Any help ?

Is it bad design ?

thanks in advance
- R.

email : rrn at r e sign from dk

--

Nov 16 '05 #1
4 1546
One change you might consider is for your Observer objects to be invoked as
delegate methods by the observed object. Then you 1) wouldn't need thread
timers, and 2) the delegates could be invoked asynchronously, meaning you
wouldn't have to explicity create threads. The delegates would fire on
threads from the pool, which is managed by the .NET runtime.

It sounds like you have multple threads attempting towrite to on resource
(the datagrid). The access to the datagrid should be synchronized. Also,
only the GUI thread can update the datagrid, not your other threads.

kevin aubuchon

"- R" <ig****@resign. dk> wrote in message
news:Xn******** *************** ********@63.223 .5.246...
Hello all.

I'm new to .Net so please help me out.

I have a application with several "Threads" running to observe various
things. From time to time each thread need to add an log entry, which is
displayed on a form (a datagrid on a form)

there is no database, but i created a dataset using the designer. One
Entity/Table is called Log and contains the log-entries.

The main window opens a OberverHandler class, which opens all the observer- objects, that contains a timer each (a Threading timer)

Each observer got a reference to ObserverHandler . So when a new log need to be written, a function on the ObserverHandler is called. This function got
a reference to the dataset through the mainwindow, and it adds the row to
the Log table.

The Log form got a dataView and a ddataGrid. The datagrid.dataso urce = the
dataview. The dataview opens and makes a = new DataView
(mainWindow.dat aset.tables["Log"]) - and is running.

The log-form starts to fill up with the log-entrys, but after a short time
the application fails with a NullReferenceOb ject or a SEHException.

I tried many different things, including making a local dataTable on the
Log form and add rows to it. All with the same result. No crashes if the
log window is not opened. After it opens there goes from 30 sec's to
several minutes before it crashed.

Any help ?

Is it bad design ?

thanks in advance
- R.

email : rrn at r e sign from dk

--

Nov 16 '05 #2
- R wrote:
Hello all.

I'm new to .Net so please help me out.

I have a application with several "Threads" running to observe various
things. From time to time each thread need to add an log entry, which is
displayed on a form (a datagrid on a form)

there is no database, but i created a dataset using the designer. One
Entity/Table is called Log and contains the log-entries.

The main window opens a OberverHandler class, which opens all the
observer- objects, that contains a timer each (a Threading timer)

Each observer got a reference to ObserverHandler . So when a new log need
to be written, a function on the ObserverHandler is called. This function
got a reference to the dataset through the mainwindow, and it adds the row
to the Log table.

The Log form got a dataView and a ddataGrid. The datagrid.dataso urce = the
dataview. The dataview opens and makes a = new DataView
(mainWindow.dat aset.tables["Log"]) - and is running.

The log-form starts to fill up with the log-entrys, but after a short time
the application fails with a NullReferenceOb ject or a SEHException.

I tried many different things, including making a local dataTable on the
Log form and add rows to it. All with the same result. No crashes if the
log window is not opened. After it opens there goes from 30 sec's to
several minutes before it crashed.

Any help ?

Is it bad design ?

thanks in advance
- R.

email : rrn at r e sign from dk

--


Maybe you need a Mutex
Nov 16 '05 #3
- R
"Kevin Aubuchon" <ke************ @sbcglobal.net> wrote in
news:BU******** ***********@new ssvr24.news.pro digy.com:
One change you might consider is for your Observer objects to be
invoked as delegate methods by the observed object. Then you 1)
wouldn't need thread timers, and 2) the delegates could be invoked
asynchronously, meaning you wouldn't have to explicity create threads.
The delegates would fire on threads from the pool, which is managed by
the .NET runtime.

It sounds like you have multple threads attempting towrite to on
resource (the datagrid). The access to the datagrid should be
synchronized. Also, only the GUI thread can update the datagrid, not
your other threads.

kevin aubuchon
Just so i'm 100% sure.
I'm currently looking at invoking the ObserverHandler functions from each
Observer object. I'm reading your response as the opposite, namely create
a reference to each ObserverObject from the ObserverHandler (as today),
BUT then let the ObserverHandler trigger the timer event on each
observerObject through invoke methods ??

If this is correct, i have a small problem. Each Observer run at a
different time-delay. Something are just more critical than others.
Can this be achieved with the threadPool ?

Will each Observer not be executed on its own thread, and thereby in
theory still have two ObserverObjects trying to write at the same time ?

And a bonus question - how can one use the whole invoke thing on a normal
class object ? I thought it was related to Components - and i just have a
class (the ObserverHandler ) - and cannot find the invoke method on it ?
(I just started looking into threading and invoke, so please be patient
with me)

Thanks for your answars

- R
"- R" <ig****@resign. dk> wrote in message
news:Xn******** *************** ********@63.223 .5.246...
Hello all.

I'm new to .Net so please help me out.

I have a application with several "Threads" running to observe
various things. From time to time each thread need to add an log
entry, which is displayed on a form (a datagrid on a form)

there is no database, but i created a dataset using the designer. One
Entity/Table is called Log and contains the log-entries.

The main window opens a OberverHandler class, which opens all the

observer-
objects, that contains a timer each (a Threading timer)

Each observer got a reference to ObserverHandler . So when a new log
need

to
be written, a function on the ObserverHandler is called. This
function got a reference to the dataset through the mainwindow, and
it adds the row to the Log table.

The Log form got a dataView and a ddataGrid. The datagrid.dataso urce
= the dataview. The dataview opens and makes a = new DataView
(mainWindow.dat aset.tables["Log"]) - and is running.

The log-form starts to fill up with the log-entrys, but after a short
time the application fails with a NullReferenceOb ject or a
SEHException.

I tried many different things, including making a local dataTable on
the Log form and add rows to it. All with the same result. No crashes
if the log window is not opened. After it opens there goes from 30
sec's to several minutes before it crashed.

Any help ?

Is it bad design ?

thanks in advance
- R.

email : rrn at r e sign from dk

--



--

Nov 16 '05 #4
- R
Punjab Peety <pp****@outsour cers.r.us> wrote in
news:Uv******** *********@newsr ead1.news.pas.e arthlink.net:
- R wrote:
Hello all.

I'm new to .Net so please help me out.

REMOVED
--


Maybe you need a Mutex


I tried to insert various lock's (which in my book/mind is somewhat similar
to Mutex).
Now i tested some more and found a strange behaviour:
The form containing the datagrid and dataview (and a local DataTable at the
moment) - i added a button which calls the AddLog method with some dummy-
values.
This works fine.
Then one of the Observer objects inserts into the log, and it displays on
the datagrid. BUT if i try to change any column width or anything i get the
NullReferenceOb ject thing.
How can this happen after the row has been succesfully inserted into the
datatable ?

thanks for your response btw.

- R.

--

Nov 16 '05 #5

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

Similar topics

1
4509
by: Rob | last post by:
I was looking for the easiest way to take a datagrid full of data including two template columns, and export the contents of the grid into Excel by giving an "open or save as" box. I came across the following control which I thought might do it: http://www.codeproject.com/aspnet/Excel_CSV_export_button.asp However, I'm not sure if I added the control correctly to my project via VS2003 or if I am handling the Datagrid to what appears...
3
4253
by: Bill C. | last post by:
Hello, I know this has been discussed a lot already because I've been searching around for information the last few weeks. I'm trying to implement a DataGridComboBoxColumn class. I've found several examples on the web. They all seem to have problems, though that I've been unable to resolve. The most promising example I have found is at:
0
1815
by: Frnak McKenney | last post by:
One of the reasons given for the Allied victory in WWI is that the Nazi armament industry invested so much effort in creating new weapons (e.g. the jet plane) it wasn't able to develop any of them to the point of mass-production. There are days when I experience the same difficulties with C# and dotNET: there are twelve ways to do 'most _any_thing, and I wind up exploring six before I find an acceptable solution. <grin> Case in...
2
3288
by: Alpha | last post by:
I have a window application. In one of the form, a datagrid has a dataview as its datasource. Initial filtering result would give the datavew 3 items. When I double click on the datagrid to edit the selected lie item at which case I would pop up a separate dialog box to do so, in the debugging code, the dataview.count would return 0. I get a error message because I tried to get values out of a dataview that holds 0 items. Does anyone...
5
1815
by: Jason | last post by:
I've been trying to figure out a good way to do this but haven't had much luck, any input would be greatly appreciated. Basically, after a datagrid is sorted, how can I get the primary key value of the item selected by the user? That is, not the datagrid index 'location' of the item the user selected, but the value inside a column of this item the user clicked on. I would use the CurrencyManager in a windows application but I'm not...
17
2745
by: A_PK | last post by:
I have problem databinding the DataGrid with DataView/DataSet after the filter... I create the following proceudre in order for user to filter as many as they want, but the following code is only allow user to filter the first time, when they tried the second time, the speficied cast error message will prompt one.... I create a mydataset1 first, and the mydataset1 data source was getting from DataGrid.DataSource.
3
1613
by: astro | last post by:
I have a datagrid that is two levels down from the dataview (i.e. grandchild). I have spent 3 hours trying to get the syntax of determining it's real datasource (i.e. not it's source based on it's relationship with the dataview). argh! company ---> person --->contact
2
2651
by: Flack | last post by:
I have a DataGrid and a DataTable. When my form loads I create the DataTable with the appropriate columns and use it for the DataGrids.DataSource. Later on in my app, I alter the DataTable: dt.BeginLoadData(); for(int i = 0; i < _movesArrayList.Count; i++) { string columnValues = ((string)_movesArrayList).Split(COL_SEPARATOR); DataRow _moveRow = dt.NewRow();
2
2166
by: ree321 | last post by:
I tried moving an ASP.net project form 1.1 to 2.0. But I am having problems with getting the OnItemDataBound function to run for a datagrid, in 2.0. It only gets called up if AutoGenerateColumns is set to false. Is there anyway around this? Then I tried changing the datagrid to GridView and still I am having trouble getting the function to run in code behind using: Sub databoundGeneral(ByVal s As Object, ByVal e As
0
7934
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8425
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8071
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8288
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6743
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5886
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5445
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3912
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
1541
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.