Hello
I suppose that NonBlocking mode reqire a message loop to work? Am I right?
What is the easiest way to use NonBlocking mode in a windowless application?
Regards
P.C.
[SFTP client] NonBlocking mode / console app
Re: [SFTP client] NonBlocking mode / console app
NonBlocking mode is not supported in console applications. If you want us to implement the feature, please post it at our user voice forum: http://devart.uservoice.com/forums/174370-securebridge If the suggestion gets a lot of votes, we will consider the possibility to implement it.
Re: [SFTP client] NonBlocking mode / console app
I just don't have enough timeViktorV wrote:NonBlocking mode is not supported in console applications. If you want us to implement the feature, please post it at our user voice forum: http://devart.uservoice.com/forums/174370-securebridge If the suggestion gets a lot of votes, we will consider the possibility to implement it.

I have experimented with simple message pumping and it looks to handle it.
If case of anybody interested...
Code: Select all
var
AppTerminated: Boolean;
ActiveTransmission: Boolen;
{...}
procedure PumpMessagess;
var
Unicode: Boolean;
Msg: TMsg;
begin
while PeekMessage(Msg, 0, 0, 0, PM_REMOVE) do
begin
Unicode := (Msg.hwnd = 0) or IsWindowUnicode(Msg.hwnd);
TranslateMessage(Msg);
if Unicode then
DispatchMessageW(Msg)
else
DispatchMessageA(Msg);
end;
end;
procedure Wait;
var
WaitResult: DWORD;
Dummy: THandle;
begin
while ActiveTransmission and (not AppTerminated) do
begin
// event can be used to avoid potential 1 second delay
WaitResult := MsgWaitForMultipleObjects(0, Dummy, False, 1000, QS_ALLINPUT);
if WaitResult = WAIT_OBJECT_0 then // messages in queue
PumpMessagess;
{check termination condition or do anything...}
end;
end;
{.....}
ScSFTPClientInstance.UploadFile(....);
Wait;
{.....}
- you have to be really careful because some operations (like calling <TScSFTPClient>.OpenFile) can cause deadlock at DispatchMessageA/W call
- disconnect TScSFTPClient when idle to stop WM_TIMER mesages
Re: [SFTP client] NonBlocking mode / console app
The NonBlocking mode does not work in console applications, since they do not have a native window message handler. If you implement message handling on your own, as you have done, the NonBlocking mode can be used in console applications.