public static void Spawn(Form form, IBasicThreadCollection basicthreadcollection, string FileName) { // *** Threads: example // Create a new Basic (BasicNoUIObj) object Basic basic = new Basic(form); // Begin a new Basic thread and run the script in the new thread basic.Spawn_(basicthreadcollection, FileName); // *** }
// *** public BasicForm(IBasicThreadCollection basicthreadcollection) { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // // *** Threads: required basicthreadcollection_ = basicthreadcollection; // *** }
// *** internal void Spawn_(IBasicThreadCollection basicthreadcollection, string FileName) { // *** Threads: example // Begin a new Basic thread and add it to the collection BeginBasicThread(basicthreadcollection); // Invoke Spawn1 in the new thread Delegate d1 = Delegate.CreateDelegate(typeof(Spawn1Delegate), this, "Spawn1"); if (!(bool)Invoke(d1, new object[]{FileName})) throw new Exception("Spawn failed."); // Start Spawn2 in the new thread Delegate d2 = Delegate.CreateDelegate(typeof(Spawn2Delegate), this, "Spawn2"); BeginInvoke(d2, null); // *** }
// *** public static void Spawn(IBasicThreadCollection basicthreadcollection, string FileName) { // *** Threads: example // Create a new BasicForm (contains a BasicIdeCtl control) BasicForm form1 = new BasicForm(basicthreadcollection); // Attach the new form to the collection and use it's IBasicThread implementation form1.basicIdeCtl1.AttachBasicThread(form1); // Create a new thread Thread thread = new Thread(new ThreadStart(form1.ThreadProc)); // Must be a single threaded apartment thread.SetApartmentState(ApartmentState.STA); // Start the thread thread.Start(); // Run the script in the new thread form1.Spawn_(FileName); // *** }