저는 백그라운드 작업자 제어 기능이 새로 도입되었습니다. 파일을 빌드하는 기존 프로젝트가 있지만 프로젝트를 빌드하는 동안 교착 상태 오류가 발생합니다. 배경 작업자만으로 구성된 다른 프로젝트를 만들어 문제를 해결하려고합니다. 나는 그들을 합칠 것이다.배경 작업자 및 SaveDialog
내 문제는 내 배경 작업자가 어디에 구현되어야하는지 잘 모르겠지만 주요 문제는 내 백그라운드 작업자와 함께 SaveDialog를 어떻게 사용할 수 있는가하는 것입니다. 완료 될 때 내 파일이 빌드 될 때이를 알려주는 매개 변수를 내 백그라운드 작업자 프로젝트에 보내야합니다. 당신이 시도 할 수
srOutputFile = New System.IO.StreamWriter(strFile, False) 'Create File
For iSeqNo = 0 To iPrintSeqNo
' Loop through al the record types
For Each oRecord As stFileRecord In pFileFormat
If dsFile.Tables.Contains(oRecord.strRecordName) Then
' Loop through al the records
For Each row As DataRow In dsFile.Tables(oRecord.strRecordName).Rows
' Check record id
If oRecord.strRecordId.Length = 0 Then
bMatched = True
Else
bMatched = (CInt(oRecord.strRecordId) = CInt(row.Item(1)))
End If
' Match records
If iSeqNo = CInt(row.Item(0)) And bMatched Then
strRecord = ""
' Loop through al the fields
For iLoop = 0 To UBound(oRecord.stField)
' Format field
If oRecord.stField(iLoop).iFieldLength = -1 Then
If strRecord.Length = 0 Then
strTmp = row.Item(iLoop + 1).ToString
Else
strTmp = strDelimiter & row.Item(iLoop + 1).ToString
End If
ElseIf oRecord.stField(iLoop).eFieldType = enumFieldType.TYPE_VALUE Or _
oRecord.stField(iLoop).eFieldType = enumFieldType.TYPE_AMOUNT_CENT Then
strTmp = row.Item(iLoop + 1).ToString.Replace(".", "").PadLeft(oRecord.stField(iLoop).iFieldLength, "0")
strTmp = strTmp.Substring(strTmp.Length - oRecord.stField(iLoop).iFieldLength)
Else
strTmp = row.Item(iLoop + 1).ToString.PadRight(oRecord.stField(iLoop).iFieldLength, " ").Substring(0, oRecord.stField(iLoop).iFieldLength)
End If
If oRecord.stField(iLoop).iFieldLength > -1 And (bForceDelimiter) And strRecord.Length > 0 Then
strTmp = strDelimiter & strTmp
End If
strRecord = strRecord & strTmp
Next
' Final delimiter
If (bForceDelimiter) Then
strRecord = strRecord & strDelimiter
End If
srOutputFile.WriteLine(strRecord)
End If
Next
End If
Next
Next
빠른 응답을 보내 주셔서 감사합니다. 내가 스레드와 백그라운드 작업자로 새롭기 때문에 당신이하고있는 일을 간단히 설명 할 수 있을까요? 당신이하는 일을 완전히 이해하고 싶습니다. – Gericke
@ G-Man 나는 코드가하는 일을 명확히하기 위해 더 많은 코멘트를 가지고 나의 대답을 편집하고있다. – SysDragon
@ G-Man 완료. 당신이 아무것도 이해하지 못하면 그냥 물어보십시오. 미안하지만 내 설명이 명확하지 않다면. – SysDragon