.NET

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

mutiple Thread in CAD command!

236 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 (185 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 (175 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,698
Registered: ‎10-12-2006
Message 4 of 5 (160 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 (139 Views)

Re: mutiple Thread in CAD command!

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

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.