One thing I've been trying to do is get an asynchronous procedure call done (drops out when set up, fires event when done, but lets the logic continue to run afterwards). Basically put, the procedure starts up a thread and then exits, and then there is an event which fires when the procedure thread completes. The idea is to stay away from the main (VCL) thread as much as possible, except for update events.
Now, the logic is pretty simply devised and seems to work well when it comes to simple things, but harder when it comes to adding loops and other processing.
In a basic way I have something like:
when it comes to this async procedure.
Is there a smart way to handle loop & conditional logic in such a situation? E.g. if it were synchronous (doesn't go to the next statement until completely done):
pretty simplified logic regarding what I'm trying to do:
"DownloadFile" in this case has my normal async procedure call, but with a "ProcessMessages" loop after it. Anyhow in the logic, the async call needs to complete before the loop continues.
Any ideas for a way to approach this where the logic wouldn't be so convoluted, or would this be a case where it might be better to just have the "ProcessMessages" loop and be done with it?
It is not possible for anyone to acknowledge truth when their salary depends on them not doing it.
Now, the logic is pretty simply devised and seems to work well when it comes to simple things, but harder when it comes to adding loops and other processing.
In a basic way I have something like:
Code:
MyObject.DownloadFile;
procedure MyComponent.MyObjectCompleted(Sender: TObject);
begin
end;
when it comes to this async procedure.
Is there a smart way to handle loop & conditional logic in such a situation? E.g. if it were synchronous (doesn't go to the next statement until completely done):
pretty simplified logic regarding what I'm trying to do:
Code:
for i := 0 to (ListBox.Items.Count - 1) do
if ListBox.Selected[i] then
if StringList.Count > 0 then
for j := 0 to (StringList.Count - 1) do
begin
MyComponent.URL := StringList.Strings[j];
upteststr := UpperCase(MyComponent.Url);
if Condition1 or Condition2 then
DownloadFile;
end;
"DownloadFile" in this case has my normal async procedure call, but with a "ProcessMessages" loop after it. Anyhow in the logic, the async call needs to complete before the loop continues.
Any ideas for a way to approach this where the logic wouldn't be so convoluted, or would this be a case where it might be better to just have the "ProcessMessages" loop and be done with it?
It is not possible for anyone to acknowledge truth when their salary depends on them not doing it.