/// <summary> /// Adds a function to be called whenever there are no higher priority /// events pending. If the function returns <c>false</c> it is automatically /// removed from the list of event sources and will not be called again. /// </summary> /// <remarks> /// This internally creates a main loop source using <see cref="CreateSource"/> /// and attaches it to the global <see cref="MainContext"/> using <see cref="Source.Attach"/>, so /// the callback will be invoked in whichever thread is running that main /// context. You can do these steps manually if you need greater control or to /// use a custom main context. /// </remarks> /// <param name="function"> /// function to call /// </param> /// <param name="priority"> /// the priority of the idle source. Typically this will be in the /// range between <see cref="Priority.DefaultIdle"/> and <see cref="Priority.HighIdle"/>. /// </param> /// <returns> /// the ID (greater than 0) of the event source. /// </returns> public static uint Add(SourceFunc function, int priority = Priority.DefaultIdle) { if (function == null) { throw new ArgumentNullException(nameof(function)); } var(function_, notify_, data_) = UnmanagedSourceFuncFactory.CreateNotifyDelegate(function); var ret = g_idle_add_full(priority, function_, data_, notify_); return(ret); }
public static uint AddSeconds(uint interval, SourceFunc function, int priority = Priority.Default) { if (function == null) { throw new ArgumentNullException(nameof(function)); } var(function_, notify_, data_) = UnmanagedSourceFuncFactory.CreateNotifyDelegate(function); var ret = g_timeout_add_seconds_full(priority, interval, function_, data_, notify_); return(ret); }
public static uint Add(int priority, int signum, SourceFunc handler) { if (handler == null) { throw new ArgumentNullException(nameof(handler)); } var(handler_, notify_, userData_) = UnmanagedSourceFuncFactory.CreateNotifyDelegate(handler); var ret = g_unix_signal_add_full(priority, signum, handler_, userData_, notify_); return(ret); }