开发者

If I remove the MsgBox the Code fails to run, How is that possible and how to fix it?

I have a code that uses W开发者_Python百科PF Interoperability where I have WPF Item that is being added as user control in windows forms. I use the WPF for 3D view where I add a sphere dynamically and it works fine, all I do is just send x, y and radius from the form to WPF and it draws the sphere. Now here it is the problem I made a loop that reads list of coords and draws them in WPF control, it works perfectly if I add a blank MsgBox but if I remove the MsgBox it only shows the last sphere in the list, Eg

   For Each obj As Sphere in LstSpheres

        MsgBox("") 'If I remove this the code doesn't work
        CreateSphere(obj.x, obj.y, obj.radius, Brushes.Red) 'This Sub adds the Sphere in WPF Control

    Next

How is that possible, and how can it be fixed?

UPDATE:

CreateSphere

        Dim S As New Sphere ' a ready made object I took and it doesn't use threaing
        S.Radius = Radius
        S.X = x
        S.Y = y
        S.BrushColor = Color
        My3DViewport3D.Children.Add(S)


I'm curious what happens if you do something like this.

Dim temp As String = ""

For Each obj As Sphere in LstSpheres
    CreateSphere(obj.x, obj.y, obj.radius, Brushes.Red)
    temp &= "[" & My3DViewport3D.Children.Count & "]"
Next

MsgBox(temp)


My first guess would be a threading issue? Maybe the act of stopping the code for the message box allows enough time for the last CreateSphere to complete?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜