.NET

Reply
Active Contributor
huaxiamengqing
Posts: 35
Registered: ‎05-23-2012
Message 1 of 5 (219 Views)

mutiple Thread in CAD command!

219 Views, 4 Replies
02-17-2014 05:18 PM

Hi,guys.I want using mutiple threads to operate CAD. But See code below.

Imports Autodesk.AutoCAD.Runtime
Imports qApp = Autodesk.AutoCAD.ApplicationServices
'System ref
Imports Autodesk.AutoCAD.Interop
Imports System.Windows.Forms
Imports System.Windows.Forms.Integration
Imports System.Runtime.InteropServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.Geometry
Imports System.Text.RegularExpressions
Imports Seg_CADCommon.SegCommon.CAD
Imports System.Threading
      Dim  t As Thread
  Public Sub Gettid()
            Dim doc As qApp.Document = qApp.Application.DocumentManager.MdiActiveDocument
            MsgBox(doc Is Nothing)
            ' operate.Textptid.GetTid(True, doc, Mpttextlist)
        End Sub
        <CommandMethod("Ststart", CommandFlags.Session)> _
        Public Sub Ststart()
            Try
                t = New Thread(AddressOf Gettid)
                t.Start()
            Catch
            End Try
        End Sub
        <CommandMethod("Stabort", CommandFlags.Session)> _
        Public Sub Stabort()
            Try
                t.Abort()
            Catch
            End Try
        End Sub
        <CommandMethod("Stmessg", CommandFlags.Session)> _
        Public Sub Stmessg()
            Try
                'qApp.Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage(Mpttextlist.Count)
            Catch
            End Try
        End Sub

 But When I Start the thread. It tells me that doc is nothing. You can Test it. I don't understand why doc is nothing. I want use the doc in this thread.

Thank you in advance.

Valued Contributor
cdinten
Posts: 61
Registered: ‎11-19-2010
Message 2 of 5 (168 Views)

Re: mutiple Thread in CAD command!

02-17-2014 11:35 PM in reply to: huaxiamengqing
for long times it sees that AutoCAD could not support the MultiThread, if it can, sorry for my ignorance.
Valued Contributor
sszabo
Posts: 86
Registered: ‎09-05-2012
Message 3 of 5 (158 Views)

Re: mutiple Thread in CAD command!

02-18-2014 03:49 AM in reply to: cdinten

while that's what seems to be the general consensus (no multi-threading in acad plugins) I found that it is possible to have acad objects shared between threads.  Check out the following discussion: I posted a solution at end of it.  It also has links that might help in your case as well.

 

http://forums.autodesk.com/t5/NET/Catastrophic-failure-HRESULT-0x8000FFFF-E-UNEXPECTED/m-p/3765575#M...

*Expert Elite*
dgorsman
Posts: 5,104
Registered: ‎10-12-2006
Message 4 of 5 (143 Views)

Re: mutiple Thread in CAD command!

02-18-2014 07:29 AM in reply to: huaxiamengqing

What, precisely, do you need multi-threading capability for?

----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
Adopt. Adapt. Overcome. Or be overcome.
A good question will be halfway to a good answer.


Active Contributor
huaxiamengqing
Posts: 35
Registered: ‎05-23-2012
Message 5 of 5 (122 Views)

Re: mutiple Thread in CAD command!

02-18-2014 04:57 PM in reply to: sszabo
Thank for you advise

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community