External Exception on reconnection after OS Suspend

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
brace
Posts: 227
Joined: Wed 14 Feb 2007 08:26

External Exception on reconnection after OS Suspend

Post by brace » Fri 09 Apr 2010 06:59

I use one single TMSConnection in my application.

When there is a disconnection I use the OnConnectionLost event in this way to reconnect, before trying to reconnect I ask the user if he wants to reconnect (this makes sense because may be he incidentally unplugged a LAN cable or switched off wireless).

This is the code I use, I removed things specific to my app, I just left the SDAC part:

Code: Select all

procedure TForm1.OnConnectionLost(Sender: TObject; Component: TComponent;
  ConnLostCause: TConnLostCause; var RetryMode: TRetryMode);
begin
  if  MsgBox('Connection lost detected. Do You want to try to  reconnect?',
   MB_ICONWARNING + MB_YESNO) = mrYes 
    then  RetryMode := rmReconnectExecute
 else
 begin
     RetryMode := rmRaise;
     Application.Terminate;
  end;
end;

On my laptop when I close monitor the system (Windows Vista) goes on Suspended mode. As I open the screen again the OnConnectionLost event fires and I am propmpt to reconnect. Sometimes (not always) the first time I try to open a dataset in my application it doesn't work and I have an

External Exception: C00000006

error.

I must kill the application in Task Manager.

May you give some advice about that external exception?

Thanks.

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Mon 12 Apr 2010 12:47

Please, try to compose a small sample to demonstrate the problem and send it to dmitryg*devart*com.

brace
Posts: 227
Joined: Wed 14 Feb 2007 08:26

Post by brace » Wed 14 Apr 2010 14:42

may be I got the problem:

the OnConnectionLost event doesnt' dire immedaitely. Imagine I disconnect LAN cable from machine.

I have some timers in my application.

During OnConnectionLost event handler I set a ConnectionLost flag to True.

in timers execution code i check for ConnectionLost to be False.

Anyway if the situation is this:

1) LAN disconnection
2) Timer.Execute
3) OnConnectionLost

I have the problem... May this be? Becuse it isnot a 100% reproducable behaviour.

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Fri 16 Apr 2010 08:01

I did not fully understand what you mean. Please give a sample of a code that you are using.

Post Reply