.NET

Reply
Active Contributor
35 Posts
0 Kudos
Registered: ‎05-23-2012
Post 1 of 5

mutiple Thread in CAD command!

239 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
61 Posts
0 Kudos
Registered: ‎11-19-2010
Post 2 of 5

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
86 Posts
11 Kudos
Registered: ‎09-05-2012
Post 3 of 5

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*
5,745 Posts
501 Kudos
Registered: ‎10-12-2006
Post 4 of 5

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
35 Posts
0 Kudos
Registered: ‎05-23-2012
Post 5 of 5

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