스레드에 문제가 있습니다. 내 코드 :이 형태는 타이머를 가지고 (iForm에서 사용자의 입력을받을 필요가 있기 때문에 내가 ShowDialog를 사용하고다른 스레드의 대화 상자 닫기
public String Parse(String url,CancellationToken ct)
{
ct.ThrowIfCancellationRequested();
/* many lines of code */
InputForm iForm = new InputForm();
iForm.setPageData(pageData);
if (iForm.ShowDialog() == DialogResult.OK)
{
string userInput = iForm.textBox.Text;
/* code block */
return result;
} else {
return Parse(newUrl,ct);
}
}
을 자동 60 초 후에 닫혀 : 구문 분석에서 지금
Task.Factory.StartNew(() =>
{
cts = new CancellationTokenSource();
var lines = File.ReadLines(Path.Combine(Environment.CurrentDirectory, "urls.txt"));
try
{
var q = from line in lines.AsParallel().WithDegreeOfParallelism(30).WithCancellation(cts.Token)
let result = Parse(line, cts.Token)
select new
{
res = result
};
foreach (var x in q)
{
if (x != null)
{
Console.WriteLine("{0}", x.res);
}
}
}
catch (OperationCanceledException ex)
{
Console.WriteLine(ex.Message);
}
});
내가 가진). 이제 약 30 개의 양식을 열고 취소 (기본 양식에서)를 클릭하면이 대화 상자 양식을 수동으로 닫아야합니다. 취소를 클릭하면이 양식을 닫을 수 있습니까?
이것은 Windows Form 또는 WPF입니까? "문제"는 무엇입니까? – CodingGorilla
Windows Form. 문제는 내가 열린 대화 상자를 자동으로 닫는 방법을 모른다는 것입니다. – JanZiolko
나는'Close' 메서드를 호출하는 것으로 이해하고 있는지 잘 모르겠습니다. 네가 묻고있는거야? – CodingGorilla