I have created a script that set up an UI in the MainTread and listens to a TCPIP server with a TimerThread.
On certain TCPIP commands I have to come back to the MainTread and execute a Rhino-Command (rs.Command("_-Import _Enter"))
This did not work so I have prepared a simple example (please have a look to code below)
In this example a TimerThread is started.
The TimerThread executes the Rhino function InvokeOnMainUiThread.
This function does not work properly, since the referenced function is executed in the TimerThread and not in the MainThread.
Please have a look to my example and drop me a line why function does not work.
Maybe there is a work around?
# -*- coding: utf-8 -*-
Created on Thu Aug 20 14:31:27 2015
@author: Daniel Härter, Z-LASER
import rhinoscriptsyntax as rs
import clr, System, threading, time
#============================= MAIN LOOP ===========================
print('Thread Name of Main Function = '+str(threading.current_thread().name))
# Timer thread
timerThread = threading.Thread(target=thread_loop)
timerThread.daemon = True
#============================= Test Function ===========================
print('Thread Name of Test Function = '+str(threading.current_thread().name))
from IronPython.Compiler import CallTarget0
delegate = CallTarget0(test)
#============================= Thread Loop ===========================
for i in range(3):
print('Run thread '+str(i))
# Execute it...
if( __name__ == "__main__" ):