SenseNet.ContentRepository.Tests.Workflow.WfWatcher.WaitForFinished C# (CSharp) Method

WaitForFinished() public static method

public static WaitForFinished ( string &message ) : bool
message string
return bool
        public static bool WaitForFinished(out string message)
        {
            Duration = 0;
            while (++Duration < _timeout)
            {
                if (Finished)
                {
                    message = _message;
                    WfWatcher.ReceiveMessage();
                    return true;
                }
                Thread.Sleep(_wait);
            }
            message = _message;
            return false;
        }
    }

Usage Example

Example #1
0
        public void WF_Delay()
        {
            //if (!Node.Exists("/Root/System/WorkflowProtoTypes/DelayTest"))
            //{
            //    var prototypesFolder = Node.LoadNode("/Root/System/WorkflowProtoTypes");
            //    if (prototypesFolder == null)
            //    {
            //        prototypesFolder = Content.CreateNew("Folder", Repository.SystemFolder, "WorkflowProtoTypes").ContentHandler;
            //        prototypesFolder.Save();
            //    }
            //    var wfProto = new DelayTestWorkflow(prototypesFolder);
            //    wfProto.Name = "DelayTest";
            //    wfProto.Save();
            //}

            DelayTestWorkflow wfContent1, wfContent2;

            //-- creating workflow state contents
            wfContent1                = new DelayTestWorkflow(TestRoot);
            wfContent1.Name           = "WF1";
            wfContent1.TestInstanceId = "WF1";
            wfContent1.Timeout        = TimeSpan.Parse("00:00:00:10");
            wfContent1.Save();
            wfContent1 = Node.Load <DelayTestWorkflow>(wfContent1.Id);

            wfContent2                = new DelayTestWorkflow(TestRoot);
            wfContent2.Name           = "WF2";
            wfContent2.TestInstanceId = "WF2";
            wfContent2.Timeout        = TimeSpan.Parse("00:00:00:10");
            wfContent2.Save();
            wfContent2 = Node.Load <DelayTestWorkflow>(wfContent2.Id);

            //-- starting the workflow
            InstanceManager.Start(wfContent1);
            Thread.Sleep(10);
            InstanceManager.Start(wfContent2);

            Thread.Sleep(25 * 1000);

            wfContent1 = Node.Load <DelayTestWorkflow>(wfContent1.Id);
            Debug.WriteLine("##WF> @@@@ WorkflowStatus: " + wfContent1.WorkflowStatus);
            wfContent2 = Node.Load <DelayTestWorkflow>(wfContent2.Id);
            Debug.WriteLine("##WF> @@@@ WorkflowStatus: " + wfContent2.WorkflowStatus);

            // var result = SenseNet.Search.ContentQuery.Query("WorkflowStarted:yes .AUTOFILTERS:OFF");

            //-- checking final status
            var    expectedMessage = "Finished";
            string msg;

            if (!WfWatcher.WaitForFinished(out msg))
            {
                Assert.Inconclusive("Workflow message was not received");
            }
            Assert.IsTrue(msg == expectedMessage, String.Concat("Received message: '", msg, "'. Expected: '", expectedMessage, "'"));
        }
All Usage Examples Of SenseNet.ContentRepository.Tests.Workflow.WfWatcher::WaitForFinished