Very slow when stop debugging

Jul 22, 2011 at 9:09 AM

Hi, I am new to R.net, and find it very useful and powerful. I am a VB.net user, and I downloaded the examples from this website. I change the code into vb.net, and it work well. However, when I tried to embed the plot into a picture box, I found it very slow to stop debugging (the degugging not stop automaticly, needed to stop by hand), while this didn't exited for the case of plot using R's plot window(not embed). So could anyone tell me where the problem is? Thanks very much!

The following are the codes:

Private rPlotEngine As RDotNet.REngine

Private cbt As RDotNet.RGraphAppHook

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        'Form load

        REngine.SetDllDirectory("C:\Program Files\R\R-2.13.1\bin\i386")

        'REngine.CreateInstance("RDotNet")

        REngine.CreateInstance("RDotNet", {"-q"})

        rPlotEngine = REngine.GetInstanceFromID("RDotNet")

        '

        cbt = New RGraphAppHook()    '

        cbt.GraphControl = Me.PictureBox1

End Sub

 

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        'embed plot

        cbt.Install()

        rPlotEngine.EagerEvaluate("plot(rnorm(100))")

        cbt.Uninstall()

 

End Sub

 



Private Sub Form1_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed

        'form closed

        If rPlotEngine Is Nothing Then

           rPlotEngine.Close()

           rPlotEngine.Dispose()

        End If

 End Sub