Click here to Skip to main content
15,896,606 members
Home / Discussions / C#
   

C#

 
AnswerRe: Cointegration code for C# - not Silverlight Pin
Pete O'Hanlon13-Sep-13 1:10
mvePete O'Hanlon13-Sep-13 1:10 
GeneralRe: Cointegration code for C# - not Silverlight Pin
lordoftrades15-Sep-13 22:16
lordoftrades15-Sep-13 22:16 
GeneralRe: Cointegration code for C# - not Silverlight Pin
Pete O'Hanlon15-Sep-13 22:40
mvePete O'Hanlon15-Sep-13 22:40 
QuestionHow to generate barcode and qrcode dynamically? Pin
Sahyadri3112-Sep-13 20:51
Sahyadri3112-Sep-13 20:51 
AnswerRe: How to generate barcode and qrcode dynamically? Pin
Richard MacCutchan12-Sep-13 21:54
mveRichard MacCutchan12-Sep-13 21:54 
AnswerRe: How to generate barcode and qrcode dynamically? Pin
AngloThaiSolutions7-Oct-13 4:17
AngloThaiSolutions7-Oct-13 4:17 
QuestionConverting a date format Pin
MarkB12312-Sep-13 2:10
MarkB12312-Sep-13 2:10 
AnswerRe: Converting a date format Pin
MarkB12312-Sep-13 2:30
MarkB12312-Sep-13 2:30 
AnswerRe: Converting a date format Pin
V.12-Sep-13 2:56
professionalV.12-Sep-13 2:56 
GeneralRe: Converting a date format Pin
MarkB12312-Sep-13 3:08
MarkB12312-Sep-13 3:08 
GeneralRe: Converting a date format Pin
V.12-Sep-13 3:16
professionalV.12-Sep-13 3:16 
QuestionAuto Connect SQLConnection Pin
Midnight Ahri12-Sep-13 0:06
Midnight Ahri12-Sep-13 0:06 
SuggestionRe: Auto Connect SQLConnection Pin
Richard MacCutchan12-Sep-13 0:19
mveRichard MacCutchan12-Sep-13 0:19 
QuestionRe: Auto Connect SQLConnection Pin
Midnight Ahri12-Sep-13 3:27
Midnight Ahri12-Sep-13 3:27 
AnswerRe: Auto Connect SQLConnection Pin
Richard MacCutchan12-Sep-13 3:32
mveRichard MacCutchan12-Sep-13 3:32 
AnswerRe: Auto Connect SQLConnection Pin
Midnight Ahri12-Sep-13 5:07
Midnight Ahri12-Sep-13 5:07 
QuestionRe: Auto Connect SQLConnection Pin
Midnight Ahri13-Sep-13 13:57
Midnight Ahri13-Sep-13 13:57 
AnswerRe: Auto Connect SQLConnection Pin
Richard MacCutchan13-Sep-13 22:05
mveRichard MacCutchan13-Sep-13 22:05 
AnswerRe: Auto Connect SQLConnection Pin
Midnight Ahri14-Sep-13 20:12
Midnight Ahri14-Sep-13 20:12 
AnswerRe: Auto Connect SQLConnection Pin
Pete O'Hanlon12-Sep-13 5:18
mvePete O'Hanlon12-Sep-13 5:18 
AnswerRe: Auto Connect SQLConnection Pin
Midnight Ahri12-Sep-13 5:36
Midnight Ahri12-Sep-13 5:36 
QuestionRe: Auto Connect SQLConnection Pin
Midnight Ahri12-Sep-13 6:45
Midnight Ahri12-Sep-13 6:45 
AnswerRe: Auto Connect SQLConnection Pin
Pete O'Hanlon12-Sep-13 8:13
mvePete O'Hanlon12-Sep-13 8:13 
QuestionRe: Auto Connect SQLConnection Pin
Midnight Ahri12-Sep-13 19:36
Midnight Ahri12-Sep-13 19:36 
Thank you very much for your instruction,
This is what I done.
C#
private void SQLClientLoader_Load(object sender, EventArgs e)
        {
            this.GetSQLState();
        }

C#
async private System.Threading.Tasks.Task<ConnectionState> GetStateAsync()
        {
            do
            {
                this.cts = new CancellationTokenSource();
                this.cnn = new SqlConnection(this.par.Constr);

                try
                {
                    await Task.Delay(2500);

                    await this.cnn.OpenAsync(cts.Token);
                }
                catch (Exception ex)
                {
                    cts.Cancel(false);

                    this.cnn.Dispose();
                    this.cts.Dispose();
                }
            } while (this.cnn.State != ConnectionState.Open);

            return this.cnn.State;
        }

C#
async private void GetSQLState()
        {
            

            if (await GetStateAsync() == ConnectionState.Open)
            {
                this.Close();
            }

            await Task.Delay(2500);
        }

It's working.
I used cancellation token, but why the OpenAsync() is not cancelled and still queue up?

Edit :
Found my solution.
Clear the connection pool, made my day guys.
Thank you helping me. Laugh | :laugh:

modified 13-Sep-13 21:43pm.

QuestionRunning SQL Server 2008 R2 without user interaction Pin
WaseemAmin11-Sep-13 21:49
WaseemAmin11-Sep-13 21:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.