Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic How to lock updates on another thread? (Read 1594 times)
Necroman
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 49
Joined: Jul 27th, 2009
How to lock updates on another thread?
Nov 22nd, 2010 at 3:34pm
Print Post  
Hi,
I got this problem - I use diagram initializer routine for creating and loading the Diagram object in background thread (it takes about 5 seconds, if it runs on UI thread - it freezes whole UI), unfortunately during this creation GDI methods are called and calling GDI in non-UI thread might cause exceptions. Is there a way how to disable drawing of objects on non-UI thread?

Code
Select All
at System.Drawing.Graphics.MeasureCharacterRanges(String text, Font font, RectangleF layoutRect, StringFormat stringFormat)
at MindFusion.Drawing.GdiGraphics.MeasureCharacterRanges(String text, Font font, RectangleF layoutRect, StringFormat stringFormat)
at MindFusion.Text.Word.UpdateMeasures(IGraphics graphics, Font font)
at MindFusion.Text.StyledText.StyledWord.UpdateMeasures(IGraphics graphics, Font font)
at MindFusion.Text.Text.Setup(String text, IGraphics graphics, Font font)
at MindFusion.Diagramming.TableNode.Cell.xd1bdd0ee5924b59e()
at MindFusion.Diagramming.TableNode.Cell.set_Text(String value)
at xy.Diagrams.DiagramDesigner.PaintRow(TableNode node, Int32 row, Guid projectItemID, xyobj obj)
at xy.Diagrams.DiagramDesigner.PaintList(TableNode node, xylist list)
...
-----
this is called on the top of callstack:
[DllImport("gdiplus.dll", CharSet=CharSet.Unicode, SetLastError=true, ExactSpelling=true)]
internal static extern int GdipGetStringFormatMeasurableCharacterRangeCount(HandleRef format, out int count);
-----
this is thrown
return new ArgumentException(SR.GetString("GdiplusInvalidParameter"));
 


Thanks Smiley
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to lock updates on another thread?
Reply #1 - Nov 22nd, 2010 at 3:50pm
Print Post  
Hi,

The diagram should not call drawing code when not shown inside a DiagramView, but perhaps the text measuring methods are always called when using styled text. You could try setting up the tables with EnableStyledTxt set to false, and enabling it from the main thread only after the background one exits.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Necroman
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 49
Joined: Jul 27th, 2009
Re: How to lock updates on another thread?
Reply #2 - Nov 22nd, 2010 at 4:33pm
Print Post  
It works! Smiley
Thanks a lot - I've disabled the EnableStyledTxt property when creating diagram in background thread and then enabled at the end in UI thread.
This might be probably mentioned somewhere in Documentation - possible problem in non-UI thread.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint