本文介绍了背景工作者和SaveDialog的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 大家好, 我是背景工人控制的新手。我有一个现有的项目来构建文件但是在我的项目中构建文件时我遇到了死锁错误。 我试图通过创建另一个只包含后台工作者的项目来解决它。然后我会合并它们。 我的问题是我不知道哪里对我的后台工作人员实施更有效,而且主要问题是如何将SaveDialog与后台工作者一起使用?我需要向我的后台工作项目发送一个参数,告诉它我的文件何时正在构建时完成。 这是我的文件构建的地方:Hi Guys,I am very new with Background worker control. I have an existing project that builds file but throughout my project while building files I get the deadlock error.I am trying to solve it by creating another project that will only consist out of the background worker. I will then merge them.My problem is I don''t know where it will be more effective for my background worker to be implemented and also the main problem is how can I use the SaveDialog with my background worker? I need to send a parameter to my background worker project telling it when my file is being build en when it is done.This is where my file is being build:' Create file srOutputFile = New System.IO.StreamWriter(strFile, False) 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 这是我如何在SaveToolStripMenu事件中调用我的方法: oDisplayFile.sbWriteFile(ToolStripFileName.Text) 任何帮助将不胜感激,and this is how I call my method in my SaveToolStripMenu event:oDisplayFile.sbWriteFile(ToolStripFileName.Text)Any help would be much appreciated,推荐答案 这篇关于背景工作者和SaveDialog的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 06-18 22:36