[fpc-pascal] Running a background process

Skybuck@home.nl skybuck at home.nl
Sat Jan 15 18:20:39 CET 2005


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.


















More information about the fpc-pascal mailing list