Threading SharpPlot

General APL language issues
Post Reply
paulmansour
Posts: 431
Joined: Fri Oct 03, 2008 4:14 pm

Threading SharpPlot

Post by paulmansour »

Hello all, and Merry Christmas!

I'm having some trouble multithreading SharpPlot. It appears to really not like operating in a thread. My stuff just hangs the interpreter. I also notice that while this works:
⎕SE.UCMD 'Chart ⍳10'
this does not:
⎕SE.UCMD &'Chart ⍳10'
Though it does not hang the interpreter.

Worse though is that it is not consistent. Some time it works, sometime it doesn't.

Before I spend hours trying to get a consistent, simple repro, anyone have any ideas or thoughts?
User avatar
Adam|Dyalog
Posts: 143
Joined: Thu Jun 25, 2015 1:13 pm

Re: Threading SharpPlot

Post by Adam|Dyalog »

It should be noted that the chart wizard already runs in its own thread, so you can use ]chart twice to work on two different charts simultaneously, while the session is free for use too.
paulmansour
Posts: 431
Joined: Fri Oct 03, 2008 4:14 pm

Re: Threading SharpPlot

Post by paulmansour »

If the Chart wizard runs in its own thread, wouldn't that be a 2 instead of a 1 below?
)reset
      ]Chart ⍳10 
      +{}&0
1
In addition, there is no need to use multi-threading to have multiple instances of a GUI app running in a single interpreter, and still have access to session, so not sure why it would be implemented like that, but I don't see how it could be anyway given the above output. And there does not appear to be an ampersand anywhere in the 6,973 lines of the chart wizard script.
User avatar
Adam|Dyalog
Posts: 143
Joined: Thu Jun 25, 2015 1:13 pm

Re: Threading SharpPlot

Post by Adam|Dyalog »

You're right. I completely forgot that it is a GUI app.

Sorry for the noise.
paulmansour
Posts: 431
Joined: Fri Oct 03, 2008 4:14 pm

Re: Threading SharpPlot

Post by paulmansour »

No problem. There is definitely something wrong with the SharpPlot dll and threading... but I haven't figured out exactly what yet...
Vince|Dyalog
Posts: 439
Joined: Wed Oct 01, 2008 9:39 am

Re: Threading SharpPlot

Post by Vince|Dyalog »

Hi Paul,

I think SharpPlot is intended to work in multiple threads as it said this in the release notes in 2006: "Multi-threading - in some cases it was possible for two instances of SharpPlot to interfere
when running on the same process in different threads. This has now been fixed."

Also, you can look at the script in the chart wizard. This might help remove some moving parts by eliminating the use of UCMD (user commands).

This is the script that I see if I start with ]chart ⍳10 and then look at File->View Script.

⍝ Global page set-up
⎕USING←',sharpplot.dll' ',system.drawing.dll' ⍝ you probably want to localise ⎕USING
⍝ To use cross-platform SharpPlot, comment the above and un-comment below
⍝ :If 0=⎕NC'Causeway' ⋄ (System.Drawing←System←⍎'Causeway'⎕NS'').(⎕CY'sharpplot') ⋄ :EndIf ⍝ workspace copied only once if Causeway and System are not localised
sp←⎕NEW Causeway.SharpPlot

⍝ Chart1 (Bar)
sp.BarChartStyle←Causeway.BarChartStyles.TicksBetween
sp.BarLimit←10000
sp.XAxisStyle←Causeway.XAxisStyles.(AngledLabels+MiddleLabels)
sp.YAxisStyle←Causeway.YAxisStyles.(ForceZero+GridLines)
sp.DrawBarChart ⊂,⊂⍳10

⍝ (⎕NEW Causeway.SharpPlotViewer sp).Show ⍬ ⍝ Uncomment this line to view the chart (Windows IDE)
⍝ 3500⌶sp.RenderSvg Causeway.SvgMode.FixedAspect ⍝ Uncomment this line to view the chart (RIDE)

Regards,

Vince
User avatar
JoHo
Posts: 37
Joined: Sat Nov 28, 2009 12:51 pm
Location: Austria, EU

Re: Threading SharpPlot

Post by JoHo »

I think the word for the 2006 release notes is: thread-safe.
SCNR
Post Reply