Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2005-01

Running a background process

2 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Unknown author

Hi,

As I mentioned in my previous post I would like to develop a text based application... possibly with a text based gui.

I have one little problem.

I would like the program to do stuff while it waits for user input. Let's call "do stuff" the "background process".

In a windows console program this would be really easy. I would simply use writeln and readln etc to read commands etc and display stuff etc... and use a second Tthread to do the background stuff.

But after I developed the text based application I want to build it to all other targets...

For now dos, linux and windows will do... but later maybe also beos and amiga... I was hoping that free pascal could also target C64 ! That would be super cool =D

Anyway...

The problem is a little bit with readln and readkey etc...

Readln will simply block the process etc. Dos doesn't have multi threaded support ???

I could do it as follows:

while running do
begin
    if KeyPressed then
    begin
        ReadLn(Command);
    end;
    BackgroundProcess.SingleLoop; // ;) etc
end;

So far this seems the most easy and best solution

BUT

While the user is typing a command the whole program will freeze etc...

That's a bit unfortunate. I would like the background process singleloop to continue while the user enters his commands etc...

Euhm any solutions ?

Well I have thought of one solution and that's the CLX thing... or Turbo Vision thing... it's a text based gui... and if I am not mistaken it also has some sort of Idle Loop etc...

That's why I mentioned CLX in my previous post.

Well maybe somebody in this mailing list found a nice trick for console application in dos with background processess ? which is even target independant or something ?

I have seen DWPL and it's stack use some sort of Multi Threading in Dos etc... but I don't know if it's cross platform and stable etc.. probably not ;)

Bye,
Skybuck.

Peter Vreman
to Unknown author
Show quoted text 14 lines
Hi, As I mentioned in my previous post I would like to develop a text based application... possibly with a text based gui. I have one little problem. I would like the program to do stuff while it waits for user input. Let's call "do stuff" the "background process". In a windows console program this would be really easy. I would simply use writeln and readln etc to read commands etc and display stuff etc... and use a second Tthread to do the background stuff.

TTHread is supported

Show quoted text 14 lines
But after I developed the text based application I want to build it to all other targets... For now dos, linux and windows will do... but later maybe also beos and amiga... I was hoping that free pascal could also target C64 ! That would be super cool =D Anyway... The problem is a little bit with readln and readkey etc... Readln will simply block the process etc. Dos doesn't have multi threaded support ???

It has no multithread support

Show quoted text 27 lines
I could do it as follows: while running do begin if KeyPressed then begin ReadLn(Command); end; BackgroundProcess.SingleLoop; // ;) etc end; So far this seems the most easy and best solution BUT While the user is typing a command the whole program will freeze etc... That's a bit unfortunate. I would like the background process singleloop to continue while the user enters his commands etc... Euhm any solutions ? Well I have thought of one solution and that's the CLX thing... or Turbo Vision thing... it's a text based gui... and if I am not mistaken it also has some sort of Idle Loop etc...

Free Vision is available

Show quoted text 10 lines
That's why I mentioned CLX in my previous post. Well maybe somebody in this mailing list found a nice trick for console application in dos with background processess ? which is even target independant or something ? I have seen DWPL and it's stack use some sort of Multi Threading in Dos etc... but I don't know if it's cross platform and stable etc.. probably not ;)

CLX is Windows/Linux only and not made with the idea of being cross example no MacOSX or AMD64 (64bit) support.