예제 #1
0
        /// <summary>
        /// Creates a Csound6NetThread and starts it up passing userdata to the Run
        /// method provided by runnable.
        /// </summary>
        /// <param name="runnable">A threadable program with a Run(userdata) method implemented</param>
        /// <param name="userdata">any object to be passed to the newly initiated thread when it starts up</param>
        public Csound6NetThread(ICsound6Runnable runnable, object userdata)
        {
            Runnable = runnable;
            UserData = userdata;
            GCHandle gch = GCHandle.Alloc(userdata);                                          //GCHandle will be freed by RunInternal upon startup

            m_thread = NativeMethods.csoundCreateThread(RunInternal, GCHandle.ToIntPtr(gch)); //need to put this as pointer
        }
예제 #2
0
 /**
  * \addtogroup THREADING
  * @{
  */
 /// <summary>
 /// Creates a Csound6Thread using the provided runnable.
 /// Convenience constructor for the common use case where the runnable
 /// object is also the user data object.
 /// Unlike in the "c" api, merging the threaded action and the data into
 /// a single object is a more convenient way to work.
 /// </summary>
 /// <param name="runnable"></param>
 public Csound6NetThread(ICsound6Runnable runnable)
     : this(runnable, runnable)
 {
 }