Re: [MSEide-MSEgui-talk] Some question about MSE thread...

2017-07-16 Thread Fred van Stappen
Re-hello Martin.


In previous mail, do not take too much attention with:

function Tmymsethread.ExecuteLoop : threadprocty;

It has absolutely no sense, only to show you that I am loosed with the use of 
mse main-thread-loop.

Fre;D
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
mseide-msegui-talk mailing list
mseide-msegui-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk


Re: [MSEide-MSEgui-talk] Some question about MSE thread...

2017-07-16 Thread Fred van Stappen
Hello Martin.

OK, the conversion (seems) done.
There are no more errors, crashs nor warnings.
But there is no sound too.  ;-(

I do not catch what to do with the main-procedure-loop of the mse thread.

With a fpc TThread, the main-procedure-loop is the published "Execute" 
procedure.
So the one has to override it to use it.

Here what I did for mse:

Tmymsethread = class(tmsethread)
ExecuteLoop: threadprocty;
hasstarted: boolean ;
procedure start;
constructor create(const athreadproc: threadprocty;
const afreeonterminate: boolean = false;
const astacksizekb: integer = 0);
end;


constructor Tmymsethread.create(const athreadproc: threadprocty;
const afreeonterminate: boolean = false;
const astacksizekb: integer = 0);
   begin
   hasstarted := false;
   inherited Create(executeloop, true, astacksizekb);
   end;

// The Main Loop Procedure
function Tmymsethread.ExecuteLoop : threadprocty;
begin
while hasstarted = false do sleep(10); // this because there is no 
CreateSuspended mse parameter.

while // here the big loop
...
end;

// to start the big loop:
procedure start;
begin
hasstarted := true;
end;

But after start, nothing appends.

Other thing.
I use RTLEvent for pausing threads.
Does msethreads accept it ?

Thanks.

Fre;D

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
mseide-msegui-talk mailing list
mseide-msegui-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk


Re: [MSEide-MSEgui-talk] Some question about MSE thread...

2017-07-16 Thread Fred van Stappen
Hello Martin.


Wow.


OK, I will add a new line in define.inc of uos -->


{.$DEFINE mse}   // when using a mse project uncomment for building using mse 
thread and timer


... and adapt uos code for that new define.


Write you later.


Fre;D


De : Martin Schreiber 
Envoyé : dimanche 16 juillet 2017 07:32
À : mseide-msegui-talk@lists.sourceforge.net
Objet : Re: [MSEide-MSEgui-talk] Some question about MSE thread...

On Sunday 16 July 2017 00:04:48 Fred van Stappen wrote:
> Hello Martin
>
> Some question about MSE threads (tthreadcomp?)...
>
> Mainly how to convert fpc TThread into mse tthreadcomp...
>
> How do you convert this in mse code (+ some tips are welcome)?
>
>
> TMSEthread = class(TThread) >  TMSEthread = class(tthreadcomp) > ok
> ?
>
tthreadcomp is a container of teventthread which can be placed in a form.
In order to replace a FPC TThread one probably would use tmsethread or one of
its descendants (tmutexthread -> tsemthread -> teventthread). tmutexthread
has a mutex, tsemthread a semaphore and teventthread an event queue.

> constructor TMSEthread.Create(CreateSuspended: boolean;
>   const StackSize: SizeUInt) > ?
>
   constructor create(const athreadproc: threadprocty;
const afreeonterminate: boolean = false;
const astacksizekb: integer = 0); overload; virtual;

> destructor Destroy; override > ?
>
   destructor destroy; override;

> procedure Execute; override > ?
>
   function execute(thread: tmsethread): integer; virtual;

> procedure DoTerminate; override > ?
>
Does not exist, there is tthreadcomp.onterminate and tthreadcomp.onterminated.
> ...
>
> TMSEthread.Start > ?
>
tmsethread starts automatically, there is tthreadcomp.active.

> TMSEthread.Queue > ?
>
application.postevent(). Often application.lock()/unlock() is more convenient.

> TMSEthread.FreeOnTerminate := true > ?
>
tmsethread.freeonterminate:= true;

> TMSEthread.Priority := tpTimeCritical > ?

Not implemented.

> ...
>
> About using MSEThreads outside a MSE project...
> Is it possible?

Not easy, it needs the MSE-infrastructure.

Martin

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
mseide-msegui-talk mailing list
mseide-msegui-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
mseide-msegui-talk Info Page - 
SourceForge
lists.sourceforge.net
mseide-msegui-talk -- General list for MSEide+MSEgui About mseide-msegui-talk



--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
mseide-msegui-talk mailing list
mseide-msegui-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk


Re: [MSEide-MSEgui-talk] TSlider and onmouseevent/onkeydown/onkeyup ?

2017-07-16 Thread Fred van Stappen

Thanks Martin.


I will deeply study your answer.


Write you later.


Fre;D


De : Martin Schreiber 
Envoyé : dimanche 16 juillet 2017 05:17
À : mseide-msegui-talk@lists.sourceforge.net
Objet : Re: [MSEide-MSEgui-talk] TSlider and onmouseevent/onkeydown/onkeyup ?

On Saturday 15 July 2017 18:38:28 Fred van Stappen wrote:
> > In order to trigger value settings before releasing the mouse button
> > activate .scrollbar.options sbo_thumbtrack (default true).
>
> Yep, perfect, I get exactly what I want, thanks.
>
> > For the the problem with the thread I would do
>
> Oooops, that is much more complicated than using:
> "onmouseevent" + "onkeyup" + "onkeydown" with "Slider1.tag := 0 (or 1);".
>
You need to call application.lock()/unlock() or use another synchronizing
mechanism while accessing main thread elements from a worker thread or there
will be problems (most likely crashes) sooner or later. How do you protect
gui resources in your code?

"
   if not tslider1.clicked then begin
"
replaces your
"
procedure ASlider.onmousedown(sender: TObject); // idem for onkeydown
begin
ASlider.tag := 1;
end;

procedure ASlider.onmouseup(sender: TObject); // idem for onkeyup
begin
ASlider.tag := 0;
end;

and in the loop of the thread:

...
if ASlider.tag = 0 then ASlider.position := somewhere;
"
why do you think it is "much more complicated"? your code has nine lines, mine
only one and doesn't need event properties. The code I showed is a working
example of a 0..1.0 loop in a thread in order to
demonstrate "tslider1.clicked",

> Also I use in a unit a fpc TThread (not a tthreadcomp), so your code is not
> compatible... And where/when to use that procedure?
>
application.lock()/unlock() and .clicked can be used everywhere.

Martin

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
mseide-msegui-talk mailing list
mseide-msegui-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
mseide-msegui-talk mailing list
mseide-msegui-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk