plugin problem in vb .net
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi everyone
I want to make plugin for AutoCAD but i have some problems.
I want to make plugin that connect to server, send there current image and then server do something with it and send back results.
So I am actualy making 2 plugins. One on server side, other on client side.
Server side code:
Imports System.Net.Sockets
Imports System.Text
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports System.Net
Imports System.Threading
Imports Autodesk.AutoCAD.EditorInput
Namespace serverACDrendering
Public Class Commands
Dim close As Boolean = False
Dim MAX_CLIENTS As Integer = 5
Dim queue(MAX_CLIENTS) As ClientWrapper
Dim currentClient As Integer = 0
<CommandMethod("StartServer")>
Public Sub StartServer()
For i As Integer = 0 To MAX_CLIENTS
queue(i) = Nothing
Next
Dim receiverThread As Thread = New Thread(AddressOf receiver)
Dim transmitterThread As Thread = New Thread(AddressOf transmitter)
receiverThread.Start()
Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
ed.WriteMessage("\nreceiver thread started\n}")
transmitterThread.Start()
ed.WriteMessage("\ntransmitter thread Started\n")
While (Not close)
ed.WriteMessage("\nCreated both threads... Time to rock ...\n")
End While
End Sub
<CommandMethod("StopServer")>
Public Sub StopServer()
close = False
End Sub
End Class
So i have two more threads receiver thread and transmitter thread. First is getting clients and get file from them, second send results back to them.
The problem
While (Not close)
ed.WriteMessage("\nCreated both threads... Time to rock ...\n")
End WhileIn this while loop i shold take one client and do something with it.
When this loop starts i cant stop it from autocad with StopServer command (I think because autocad is busy).
I can't do this in seperate thread because autoCAD don't do multithreading.
What can i do to put this work in background ?
Regards Domen