C# : Sharing something for the toolstripprogressbar.
Written by Airslash, November 30th, 2007
Hello,
I'm not an expert on writing C# code, but I've been busy alot on a multithreaded application to manage database information. I've finally managed to get the multithreading part working, by using these forums and google, and I really would like to share something, because I think it can be annoying sometimes to get it to work right.
In my application I'm using alot of preload functions that run in a seperate thread, and a toolstripprogressbar to show the activity from 0 to 100%. Where 0 means the preload has begun, and 100 meaning the preload has ended. I'm not going to post the code on how to obtain the values because they are specific to the application, but I will post the code, rather line, for updating the toolstripprogressbar in a save way.
Code: ( text )
// Increment the progress bar. this.BeginInvoke(new MethodInvoker(delegate() { this.progressMainBar.Increment(1); } ));
I know this isn't exactly clean code, but it really does the trick in a nice way. It's probably nothing spectacular, but I can imagine people going crazy about the constant error messages that it's not allowed to access Form UI components from a seperate thread.
I hope it helps someone :)
sevilay /
December 3rd, 2007 07:13 AM
Hello, now i have some problem to ask you how i write C# in console and conection with Database, please tell me
thank you
Quote:
Originally Posted by sevilay
Hello, now i have some problem to ask you how i write C# in console and conection with Database, please tell me
thank you
|
eum, well basicly, you need to include the right namespaces depending on what database you are using. For example
if you are using a MS Sql server: using System.Data.SqlClient and System.Data;
Then you need to have a connectionstring to connect to the database, either a DataReader, DataTable or DataSet to retrieve and store the information.
|
|
|
|
Stats:
Views: 1122
Comments: 2
|
|
|
|