Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Losing connection after PC returns from sleep mode
Message
From
12/04/2019 11:22:45
 
 
To
11/04/2019 23:32:54
General information
Forum:
Visual FoxPro
Category:
Client/server
Miscellaneous
Thread ID:
01668055
Message ID:
01668061
Views:
64
>>I have several applications running on PC's and laptops. These are client/server applications where de backend is MS SQL Server 2008 R2.
>>
>>I've learned many years ago, that, in order for the database server to save resources, always create remote views with connection sharing activated. Oh, I forgot to mention that I always use remote views in my apps (I'still don't get it how to use CursorAdapters yet).
>>
>>So, in all my applications I open a dummy remote view from the beginning, so that all the views that are open after that in the app, they all share the dummy view's connection handle. I even set that dummy view's connection handle to a public variable so that it can be used with SQL passthrough in order to execute stored procedures for the app's reports.
>>
>>However, I have a problem and it's that, for example, if a user is working with the app, then he goes to lunch without closing the app, after, say, 10 imnutes the PC goes to sleep mode, then after lunch (approximately one hour), the user returns to his PC and wants to open, say, the orders form, and the apps says that there is an error "Loading form or the data environment, Connectivity error: Error in the communication link". Another example would be when the user is working with the orders form, then goes to a meeting, without closing the form, then after 30minutes, he returns and wants to continue working with the same form, the app's connection is lost.
>>
>>What can I do to avoid that kind of situation?
>>
>>Is there a way to know when the app is returning from sleep mode?
>
>Windows sends out messages to each window telling it the machine is going to sleep. You can use BINDEVENT(_screen.hwnd, WM_POWERBROADCAST, myObj, "myHandlerMethod") to capture the event:
>
LPARAMETERS hwnd, msg, wParam, lParam
>
>See here for the wParam and lParam details:
>https://docs.microsoft.com/en-us/windows/desktop/Power/wm-powerbroadcast
>
>When it goes to sleep, manually shut down the connection. When it wakes back up, manually reestablish the connection.
>
>>At best, is there a way to make the user avoid closing and re-opening the app, so that he can continue working with the app?
>>
>>Thanks in advance.
>
>I can write it all out for you tomorrow if you'd like.

If you don't mind. Thank you.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform