Ejemplo n.º 1
0
        public void ComEnumeratorTest1()
        {
            // Test IntPtr -> string conversion
            var v1TS = new ITaskScheduler();
            var ewi  = v1TS.Enum();

            // Test IEnumerable
            var e = new IEnumFromNext <IntPtr>((out IntPtr p) => ewi.Next(1, out p, out var f).Succeeded&& f == 1, ewi.Reset);

            foreach (var p in e)
            {
                Assert.That(p, Is.Not.EqualTo(IntPtr.Zero));
                var sa = IEnumWorkItemsNames.Convert(p, 1);
                Assert.That(sa.Length, Is.EqualTo(1));
                TestContext.WriteLine(sa[0]);
            }

            // Test IEnumerator
            var g = e.GetEnumerator();

            g.Reset();
            Assert.That(g.MoveNext(), Is.True);
            g.Dispose();
            Assert.That(g.MoveNext(), Is.False);
            Assert.That(() => g.Reset(), Throws.Nothing);
        }
Ejemplo n.º 2
0
        public void ComEnumeratorTest1()
        {
            // Test IntPtr -> string conversion
            var v1TS = new ITaskScheduler();
            var ewi  = v1TS.Enum();

            // Test IEnumerable
            var e = new IEnumFromNext <IntPtr>((out IntPtr p) => ewi.Next(1, out p, out var f).Succeeded&& f == 1, ewi.Reset);
            var i = 0;

            foreach (var p in e)
            {
                Assert.That(p, Is.Not.EqualTo(IntPtr.Zero));
                i++;
            }

            // Test IEnumerator
            var g = e.GetEnumerator();

            if (i > 0)
            {
                g.Reset();
                Assert.That(g.MoveNext(), Is.True);
            }
            g.Dispose();
            Assert.That(g.MoveNext(), Is.False);
            Assert.That(() => g.Reset(), Throws.Nothing);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Return the names of all scheduled tasks.  The names returned include the file extension ".job";
        /// methods requiring a task name can take the name with or without the extension.
        /// </summary>
        /// <returns>The names in a string array.</returns>
        public string[] GetTaskNames()
        {
            const int TASKS_TO_FETCH = 10;

            string[] taskNames  = { };
            int      nTaskNames = 0;

            IEnumWorkItems ienum;

            its.Enum(out ienum);

            uint   nFetchedTasks;
            IntPtr pNames;

            while (ienum.Next(TASKS_TO_FETCH, out pNames, out nFetchedTasks) >= 0 &&
                   nFetchedTasks > 0)
            {
                taskNames = GrowStringArray(taskNames, nFetchedTasks);
                while (nFetchedTasks > 0)
                {
                    IntPtr name = Marshal.ReadIntPtr(pNames, (int)--nFetchedTasks * IntPtr.Size);
                    taskNames[nTaskNames++] = Marshal.PtrToStringUni(name);
                    Marshal.FreeCoTaskMem(name);
                }
                Marshal.FreeCoTaskMem(pNames);
            }
            return(taskNames);
        }
Ejemplo n.º 4
0
 /// <summary>
 ///     Internal constructor
 /// </summary>
 /// <param name="svc"> TaskService instance </param>
 /// <param name="filter"> The filter. </param>
 internal V1TaskEnumerator(TaskService svc, Regex filter = null)
 {
     this.svc    = svc;
     this.filter = filter;
     m_ts        = svc.v1TaskScheduler;
     wienum      = m_ts.Enum();
     Reset();
 }
Ejemplo n.º 5
0
 internal V1TaskEnumerator(TaskService svc, Regex filter = null)
 {
     _svc    = svc;
     _filter = filter;
     _ts     = svc._v1TaskScheduler;
     _wienum = _ts.Enum();
     Reset();
 }