Пример #1
0
    //INTERFACE
    /// <summary>
    /// Schedules an event to be fired at givent time
    /// </summary>
    /// <param name="time">Double type is used as time representation (in seconds). Pass simulation time (not delay).</param>
    /// <param name="method">Method to called at given time.</param>
    /// <param name="userData">User data that can be obtained from Timer Event when the method is called.</param>
    /// <returns>TimerEntry class is used as both timer ID and container having all data associated with a single event. The same objest is going to be passed to method on event.</returns>
    public static TimerEntry Schedule(double time, TimerEntryDelegate method, object userData)
    {
        Debug.Assert(time >= currentTime);

        TimerEntryImplementation entry = new TimerEntryImplementation(time, userData, method);
        //ignore entries that will take place after end of simulation.
        if (time <= simulationTime)
        {
            bool added = events.Add(ref entry.Handle, entry);
            Debug.Assert(added);
        }
        return entry;
    }
Пример #2
0
 //CONSTRUCTOR
 public TimerEntryImplementation(double time, object userData, TimerEntryDelegate method)
 {
     this.time = time;
     this.userData = userData;
     this.method = method;
 }