Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Test Internet connection
Message
De
25/01/2011 17:26:17
 
 
À
25/01/2011 15:41:16
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Versions des environnements
Visual FoxPro:
VFP 8 SP1
Divers
Thread ID:
01497336
Message ID:
01497395
Vues:
50
>>>But if there are other problems (eg invalid gateway or router info) then InternetOpenUrl() can take a minute ot so to fail.
>>>For my purposes I'd be quite happy to give up if a valid connection wasn't obtained in, say, 5 seconds.
>>
>>This is one of the best examples of useful multi-threading (or the substitutes necessary in vfp single thread...). If this is the only MT task, I'd go for a simple check in separate process writing out a file and loop with sleep-calls (or ww, as they also induce vfp-wait states) for 5s or the file is created. KISS is not always bad...
>
>You lost me. I know that if this was .Net I could hive the process off onto a separate thread - but I'd still have to wait for the result.
>Bottom line is that I'm happy to accept that if no Internet access can be confirmed in five or ten seconds then it is not available.
>I'm also not worried about maintaining any type of user interactivity whilst the check is in progress so single-threading is not a problem.

for the separate thread/process part, in simplest form in a separate exe
lpara tcfile
return StrToFile(transform(YourPossiblylongWindedInternetCheck(), m.tcFile)
base code for your fast check
local lcFile, ldExit, llHas
lcFile = sys(2015)
if file(m.lcFile)
   dele file  (m.lcFile)
endif
ldExit = datetime() + 5
CallExtProcess(m.lcFile)
do while datetime() < m.ldExit

  wait wind Datetime() timeout 1
  if file(m.lcFile)
     lcTmp = FileToStr(m.lcFile)
     llHas = eval(lcTmp)
     exit
  endif
enddo
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform