[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

5.5

progress bars with timer not working c#

Asked by flynny in C# Programming Language

hi all,

i've added a progress bar to a form. no i have a static class for handling all my sql login etc.

in the sql login method i add a time out of 24 seconds, now i want to show progress (rather than appering to hang) for my program logging in.
i have created a timer for handling the event, and it is working however it doesnt seem to be working in the seperate thread.

the code seems to hang and then after the time out accurs shoots up. am i doing somehting wrong?
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
private void Next_Button_Click(object sender, EventArgs e)
        {
            Progress_Bar.Visible = true;
            Progress_Bar.Minimum = 0;
            Progress_Bar.Maximum = 24;
            Progress_Bar.Step = 1;
            Progress_Bar.Value = 0;
            timer1.Enabled = true;
            
            //call the check server method to continue
            if (Test_Server())
            {
                NewPage2 form = new NewPage2();
                form.Show();
                close_dialog = true;
                this.Close();
            }
 
            Progress_Bar.Value = 24;
        }
 
the test_server method is basically just calling this method in my static class
 
      //Here is where I create my connection.
        private static SqlConnection createConn()
        {
            //Here you have your connection string you can edit it here.
            //need to check if we have a DSN or not.
            //also need to add username and password
            string mySqlConnectionString = buildConnString();
            
            //If you wish to use SQL security, well just make your own connection string...
            //I make sure I have declare what mySqlConnection stand for.
            if (mySqlConnection == null) { mySqlConnection = new SqlConnection(); };
 
            // Since i will be reusing the connection I will try this it the connection dose not exist.
            if (mySqlConnection.ConnectionString == string.Empty || mySqlConnection.ConnectionString == null)
            {
                // I use a try catch statement cuz I use 2 set of arguments to connect to the database
                try
                {
                    //First I try with a pool of 5-40 and a connection time out of 4 seconds. then I open the connection.
                    mySqlConnection.ConnectionString = "Min Pool Size=5;Max Pool Size=40;Connect Timeout=4;" + mySqlConnectionString + ";";
                    mySqlConnection.Open();
                }
                catch (Exception)
                {
                    try
                    {
                        //If it did not work i try not using the pool and I give it a 45 seconds timeout.
                        if (mySqlConnection.State != ConnectionState.Closed)
                        {
                            mySqlConnection.Close();
                        }
                        //changed the timeout from 40s to 20s as too long to wait.
                        mySqlConnection.ConnectionString = "Pooling=false;Connect Timeout=20;" + mySqlConnectionString + ";";
                        mySqlConnection.Open();
                    }
                    catch (Exception e)
                    {
                        CustomMessage customMessage = new CustomMessage();
 
                        //parse the exception to find out what went wrong and relay it back.
                        if (e.Message.Contains("Login failed for user"))
                            throw new CustomException.CustomException(SeverityLevel.Fatal, GlobalVars.Debuglog, e.InnerException, customMessage.GetString("Login"));
                        else if(e.Message.Contains("network-related"))
                            throw new CustomException.CustomException(SeverityLevel.Fatal, GlobalVars.Debuglog, e.InnerException, customMessage.GetString("DSN"));
                        else
                            throw new CustomException.CustomException(SeverityLevel.Fatal, GlobalVars.Debuglog, e.InnerException, customMessage.GetString("Unknown"));
                    }
                }
                return mySqlConnection;
            }
            //Here if the connection exsist and is open i try this.
            if (mySqlConnection.State != ConnectionState.Open)
            {
                try
                {
                    mySqlConnection.ConnectionString = "Min Pool Size=5;Max Pool Size=40;Connect Timeout=4;" + mySqlConnectionString + ";";
                    mySqlConnection.Open();
                }
                catch (Exception)
                {
                    try
                    {
                        if (mySqlConnection.State != ConnectionState.Closed)
                        {
                            mySqlConnection.Close();
                        }
                        mySqlConnection.ConnectionString = "Pooling=false;Connect Timeout=45;" + mySqlConnectionString + ";";
                        mySqlConnection.Open();
                    }
                    catch (Exception e)
                    {
                        CustomMessage customMessage = new CustomMessage();
 
                        //parse the exception to find out what went wrong and relay it back.
                        if (e.Message.Contains("Login failed for user"))
                            throw new CustomException.CustomException(SeverityLevel.Fatal, GlobalVars.Debuglog, e.InnerException, customMessage.GetString("Login"));
                        else if (e.Message.Contains("network-related"))
                            throw new CustomException.CustomException(SeverityLevel.Fatal, GlobalVars.Debuglog, e.InnerException, customMessage.GetString("DSN"));
                        else
                            throw new CustomException.CustomException(SeverityLevel.Fatal, GlobalVars.Debuglog, e.InnerException, customMessage.GetString("Unknown"));
                    }
                }
            }
            return mySqlConnection;
        }
[+][-]10/29/09 06:10 AM, ID: 25693188Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: C# Programming Language
Sign Up Now!
Solution Provided By: TheLearnedOne
Participating Experts: 3
Solution Grade: A
 
[+][-]09/12/09 11:41 AM, ID: 25317438Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/12/09 12:32 PM, ID: 25317596Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/14/09 05:27 AM, ID: 25324696Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/16/09 09:35 AM, ID: 25347469Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/17/09 09:08 AM, ID: 25357744Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/18/09 05:33 AM, ID: 25365203Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/18/09 05:34 AM, ID: 25365208Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/21/09 03:51 PM, ID: 25388394Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]09/21/09 03:51 PM, ID: 25388397Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]09/21/09 07:57 PM, ID: 25389280Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/21/09 11:33 PM, ID: 25390046Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]09/24/09 04:01 AM, ID: 25411897Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/25/09 01:44 PM, ID: 25427086Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]09/25/09 01:52 PM, ID: 25427143Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/28/09 08:26 AM, ID: 25440145Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/28/09 08:29 AM, ID: 25440169Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/29/09 12:38 AM, ID: 25446709Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/29/09 07:02 AM, ID: 25449096Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/14/09 08:35 PM, ID: 25577019Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/15/09 05:58 AM, ID: 25580011Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/16/09 09:24 AM, ID: 25590906Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/17/09 07:30 AM, ID: 25596027Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/19/09 05:51 AM, ID: 25604671Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/19/09 06:03 AM, ID: 25604747Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/29/09 01:48 AM, ID: 25691593Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-92 - Hierarchy / EE_QW_3_20080625