473,385 Members | 1,275 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.

Thread+Scope+Null Reference = HELP

hi,

i want to ask smt about databinding, threading etc.

this is situation:

lets say: i have a type dataset (name: "dsall")
it has datatables table1 , table2
threre are adapters which fills these and ,datagrids etc which is
databounded to this dataset

then i write this code to FORM_LOAD

//create thread in order not to wait getting process

private void formload(.......,.....)
{

Thread thr =new Thread(new ThreadStart(xx));
thr.isBackGround = true;
thr.Start();

//other things
}

private void xx()
{
adapter1.Fill(dsAll.Table1);
adapter1.Fill(dsAll.Table2);
//etc etc..
}

here is problem
when this code is executed, Null Reference exception is thrown

as i understand adapter1 creates datatable in thread scope and because
thread is ended, garbage collector collects datatable so i get null
reference exception, i say this because if i use this form there is no
error.

private void formload(.......,.....)
{

//dont use thread
//Thread thr =new Thread(new ThreadStart(xx));
//thr.Start();
//call directly function
xx();

//other things
}

but i need to fill dataset with thread

Thanks in advance

Erdem...
Nov 16 '05 #1
0 937

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

Similar topics

1
by: magic man via .NET 247 | last post by:
hi everyone i have a c# application that uses multithreading toconnect to sql server and execute a stored procedure on theserver. i am using a dataset,sqlcommand,dataadapter and adatagrid to carry...
5
by: Richard | last post by:
All, I have a worker thread that fires events across threads to both GUI objects and thread agnostic objects. My code is working but I want to be assured that it did it "the right way"... ...
2
by: bughunter | last post by:
This is partly 'for the record' and partly a query about whether the following is a bug somewhere in .Net (whether it be the CLR, JITter, C# compiler). This is all in the context of .Net 1.1 SP1. ...
7
by: Schroeder | last post by:
I have a DataSet that is cached deep down in a business layer object. Higher up, there's a merge being performed on that object and it very occassionaly throws a NullReferenceException deep down in...
165
by: Dieter | last post by:
Hi. In the snippet of code below, I'm trying to understand why when the struct dirent ** namelist is declared with "file" scope, I don't have a problem freeing the allocated memory. But...
5
by: Tony Gravagno | last post by:
I have a class that instantiates two Timer objects that fire at different intervals. My class can be instantiated within a Windows Form or from a Windows Service. Actions performed by one of the...
4
by: Diffident | last post by:
Hi All, I am trying to perform a non-CPU bound operation in an asynchronous fashion using 'Thread' and a delegate. Basically, I am spawning a thread using ThreadStart and Thread. My non-CPU...
20
by: David | last post by:
I feel like an idiot asking this but here goes: I understand the 'concept' of scope and passing data by value and/or by reference but I am confused on some specifics. class example{ int i; //my...
3
by: psroga | last post by:
Can anyone look at this code and let me know why pthread_mutex_unlock and pthread_mutex_lock are giving me the "phtread_mutex_unlock" was not defined in this scope error. I am compiling the code...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.