Multithreading support

General TRichView support forum. Please post your questions here
Post Reply
dudubaiao
Posts: 5
Joined: Thu Apr 20, 2006 5:34 pm

Multithreading support

Post by dudubaiao »

Does TRichView have support for multithreading?

I'm developing a DataSnap server application that generates RichViews on demand. If I call the remote method on 2 clients or more at the same time I get this error "Canvas does not allow drawing".

I'm not using the same TRichview for all method calls. Every method creates its own TRichView component. The only shared component is the TRVStyle.

Are there any workaround for it? I accept a sincronized-one-thread solution. :D

Thanks!
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

All operations that add items/remove/format/display document must be performed in the main thread. Use TThread.Synchronize method
dudubaiao
Posts: 5
Joined: Thu Apr 20, 2006 5:34 pm

Post by dudubaiao »

I'm using a DataSnap Server, so the remote method are running on its own thread. To simplify the things I decided to use a Critical Section.
The code is show below:

Code: Select all

procedure TDataSnapServer.GenerateRichView;
begin

 CS.Acquire;

 try

    With TfrmGenerateRichView.Create(nil) do begin
       DoGenerate;
       Free;
    End;

 finally
    CS.Release;
 end;

end;
The Critical Section is working well, but sometimes, even when I'm running a single thread, I get the Canvas error... :(

Do you guys have any tip on how to solve this?

Thanks!
shmp
Posts: 140
Joined: Sun Aug 28, 2005 10:19 am
Location: Sabah, Malaysia.
Contact:

Post by shmp »

It looks like the creation of TfrmGenerateRichView have not really formated RichView. Wild guess.
Post Reply