.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

mutiple Thread in CAD command!

4 REPLIES 4
Reply
Message 1 of 5
huaxiamengqing
658 Views, 4 Replies

mutiple Thread in CAD command!

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.

4 REPLIES 4
Message 2 of 5
cdinten
in reply to: huaxiamengqing

for long times it sees that AutoCAD could not support the MultiThread, if it can, sorry for my ignorance.
Message 3 of 5
sszabo
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...

Message 4 of 5
dgorsman
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.
"I don't know" is the beginning of knowledge, not the end.


Message 5 of 5
huaxiamengqing
in reply to: sszabo

Thank for you advise

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost