![]() |
winnet download thread
iam using this code to download some images from web to memory stream inside activex its freezing too much when large image size i asked on the web they told me to put this code inside a thread i fail to do it any help with it ? here is the code
Delphi-Quellcode:
procedure DownloadToStream(const Url: string; ms: TMemoryStream);
var hSession : HINTERNET; hService : HINTERNET; lpBuffer : array[0..1023] of Byte; dwBytesRead : DWORD; dwBytesAvail : DWORD; dwTimeOut : DWORD; begin hSession := InternetOpen('sessionname', INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0); if not Assigned(hSession) then Exit; try hService := InternetOpenUrl(hSession, PChar(Url), nil, 0, 0, 0); if hService = nil then Exit; try dwTimeOut := 60000; InternetSetOption(hService, INTERNET_OPTION_RECEIVE_TIMEOUT, @dwTimeOut, SizeOf(dwTimeOut)); if InternetQueryDataAvailable(hService, dwBytesAvail, 0, 0) then repeat Application.ProcessMessages; if not InternetReadFile(hService, @lpBuffer[0], SizeOf(lpBuffer), dwBytesRead) then Break; if dwBytesRead <> 0 then ms.WriteBuffer(lpBuffer[0], dwBytesRead); until dwBytesRead = 0; finally InternetCloseHandle(hService); end; finally InternetCloseHandle(hSession); end; end; |
AW: winnet download thread
|
AW: winnet download thread
yes here where i asked and i try to put the code on thread but fail any help
|
AW: winnet download thread
Your code doesn't show any attempt to utilize a thread, and your problem description is entirely general at best. Where exactly is your problem?
|
AW: winnet download thread
the thing is i dont know from where to start doing threading
|
AW: winnet download thread
Easies solution: Cteate a TThread object and call your function in the execute methode.
|
AW: winnet download thread
i try to do thread like this
Delphi-Quellcode:
but on thread excute what should i do
TDownloadThread = class(TThread)
public procedure Execute; override; end; |
AW: winnet download thread
Make your function a methode of your thread object and call that methode.
|
AW: winnet download thread
Zitat:
Delphi-Quellcode:
any code example will be more better
DownloadToStream(const Url: string; ms: TMemoryStream);
|
AW: winnet download thread
Add some pubic fields to your thread object for the parameters.
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 00:29 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz