public bool MoveNext()
            {
                var zero = IntPtr.Zero;
                var flag = false;

                do
                {
                    _curItem = null;
                    uint fetched = 0;
                    try
                    {
                        _wienum.Next(1, out zero, out fetched);
                        if (fetched != 1)
                        {
                            break;
                        }
                        using (var str = new CoTaskMemString(Marshal.ReadIntPtr(zero)))
                            _curItem = str.ToString();
                        if (_curItem.EndsWith(".job", StringComparison.InvariantCultureIgnoreCase))
                        {
                            _curItem = _curItem.Remove(_curItem.Length - 4);
                        }
                    }
                    catch { }
                    finally { Marshal.FreeCoTaskMem(zero); zero = IntPtr.Zero; }
                    if (_filter == null || _filter.IsMatch(_curItem))
                    {
                        try { var iCurrent = ICurrent; flag = true; }
                        catch { flag = false; }
                    }
                }while (!flag);
                return(_curItem != null);
            }
示例#2
0
            /// <summary>
            ///     Moves to the next task. See MoveNext for more information.
            /// </summary>
            /// <returns> true if next task found, false if no more tasks. </returns>
            public bool MoveNext()
            {
                var names = IntPtr.Zero;
                var valid = false;

                do
                {
                    curItem = null;
                    uint uFetched = 0;
                    try {
                        wienum.Next(1, out names, out uFetched);
                        if (uFetched != 1)
                        {
                            break;
                        }
                        using (var name = new CoTaskMemString(Marshal.ReadIntPtr(names))) {
                            curItem = name.ToString();
                        }
                        if (curItem.EndsWith(".job", StringComparison.InvariantCultureIgnoreCase))
                        {
                            curItem = curItem.Remove(curItem.Length - 4);
                        }
                    } catch {
                    } finally {
                        Marshal.FreeCoTaskMem(names);
                        names = IntPtr.Zero;
                    }

                    // If name doesn't match filter, look for next item
                    if (filter != null)
                    {
                        if (!filter.IsMatch(curItem))
                        {
                            continue;
                        }
                    }

                    ITask itask = null;
                    try {
                        itask = ICurrent;
                        valid = true;
                    } catch {
                        valid = false;
                    } finally {
                        itask = null;
                    }
                } while (!valid);

                return(curItem != null);
            }