Connecting Tech Pros Worldwide Help | Site Map
Reply
 
LinkBack Thread Tools Search this Thread
  #1  
Old November 30th, 2007, 08:52 AM
Member
 
Join Date: Nov 2007
Posts: 72
Default C# : Sharing something for the toolstripprogressbar.

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.

Expand|Select|Wrap|Line Numbers
  1. // Increment the progress bar.
  2. this.BeginInvoke(new MethodInvoker(delegate()
  3.      { 
  4.            this.progressMainBar.Increment(1); 
  5.      }
  6. ));
  7.  
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 :)
Reply



  #2  
Old December 3rd, 2007, 07:13 AM
Newbie
 
Join Date: Dec 2007
Posts: 3
Default

Hello, now i have some problem to ask you how i write C# in console and conection with Database, please tell me
thank you
Reply
  #3  
Old December 4th, 2007, 08:54 AM
Member
 
Join Date: Nov 2007
Posts: 72
Default

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.
Reply
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.