다음을 실행하면 while
루프가 끝나지 않습니다. 여기 while 루프 조건에 대한 값을 가져 오는 메소드를 호출하고 있습니다. 내가 뭘 잘못하고 있는지 말해줘?WF4의 활동 코드 조건 동안
코드 실행
using System;
using System.Linq;
using System.Activities;
using System.Activities.Statements;
using System.IO;
namespace BuildActivities
{
public sealed class CheckFile : CodeActivity
{
public InArgument<string> DirectoryName;
protected override void Execute(CodeActivityContext context)
{
Activity workflow = new Sequence
{
Activities =
{
new While
{
Condition = GetValue() ,
Body = new Sequence
{
Activities = {
new WriteLine
{
Text = "Entered"
},
new WriteLine
{
Text = "Iterating"
},
new Delay
{
Duration = System.TimeSpan.Parse("00:00:01")
}
}
}
//Duration = System.TimeSpan.Parse("00:00:01")
},
new WriteLine()
{
Text = "Exited"
}
}
};
try
{
WorkflowInvoker.Invoke(workflow, TimeSpan.FromSeconds(30));
}
catch (TimeoutException ex)
{
Console.WriteLine("The File still exist. Build Service has not picked up the file.");
}
}
public bool GetValue()
{
bool matched = false;
matched = File.Exists(@"\\vw189\release\buildservice\conshare.txt");
return matched;
}
}
}의 난 한 번만 동안 상태를 검사 생각한다. 왜냐하면, 나는 그것이 작동하는 방법을 확인하기 위해 몇 줄의 글을 썼다. 루프가 끝나지 않는 것을 알 수 있습니다. 루프가 실행 중일 때 폴더의 파일을 삭제하여 테스트합니다. 5 초마다 파일을 선택해야하는 서비스가 있습니다. 해당 서비스가 실행 중인지 여부를 확인하는 것입니다.
[이 질문에 대한] 대화 (http://stackoverflow.com/q/8066545/472495)에 따르면, 이것은 매우 유사합니다 (비록 그것이 중복인지는 모르겠지만). 왜 그 해결책이 당신을 위해 작동하지 않았는지를 설명해 주시겠습니까? – halfer
이것은 같은 질문입니다. while 루프는 작동하지 않습니다. 나는 모든 반복에 대한 조건을 검사하지 않고 따라서 반복적으로 반복한다는 것을 의미합니다. while 루프의 조건 선언이 잘못되었다고 생각합니다. 나는 그 문제에 대해 확신하지 못한다. – rishi
글쎄, while 루프 내에서 뭔가 변하는 것을 보지 못해서 조건이 false로 변경되는 것을 의심합니다. 가능한 경우 GetValue 코드와 나머지 워크 플로를 보여줍니다. – Joao