- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我目前正在尝试将进度(使用 Iprogress 和 Progress)从内部函数传递到主函数。内部功能完成后一切正常。但是,我正在使用 EBay 的 API(EBay 的查找服务,它是一种以 XML 格式返回数据的休息服务)检索/下载一些数据,并且需要在下载检索到的 XML 数据期间将进度报告从内部函数传递到主函数/数据处理。
这是主函数的代码(有点开始重载,但你知道发生了什么。为理智而评论。):
Private Property a As Integer
Get
Return a_value
End Get
Set(value As Integer)
a_value = value
' ReportProgress(value, Nothing)
End Set
End Property
Private a_value As Integer
Public Async Function EvaluateItem(item As List(Of ItemInfo), evalprogress As IProgress(Of Integer), Optional ManualEvaluation As Boolean = False) As Task(Of List(Of EvaluationInfo))
Dim notevaluatedcount As Integer = 0
Dim iteminfo1 As ItemInfo = New ItemInfo
Dim tmpiteminfo As List(Of ItemInfo) = New List(Of ItemInfo)
Dim tmpiteminfo2 As List(Of ItemInfo) = New List(Of ItemInfo)
Dim pricefunctions As ItemValuation = New ItemValuation
Dim tmpevalinfo As EvaluationInfo = New EvaluationInfo
Dim itemevalresultarr As List(Of EvaluationInfo) = New List(Of EvaluationInfo)
Dim mode As Double
Dim avg As Double
Dim min As Double
Dim max As Double
Dim standarddev As Double
Dim pricearr() As Double
Dim autoitem As List(Of EvaluationInfo) = New List(Of EvaluationInfo)
Dim itemse As New ItemInformation
' Dim itemsnoteval As New ItemInformation
' itemseval.itemsevaluated = New List(Of String)
' itemsnoteval.notevaluated = New List(Of String)
Dim tmpnoteval As List(Of ItemInfo) = New List(Of ItemInfo)
Dim ran As Boolean
'sort and store item condition information in evaluation table in database or by item.sort
If item.Count > 1 And ManualEvaluation = True Then
tmpiteminfo = SortByName(item)
Await ClearEvalTable()
tmpiteminfo2 = SortByCondition(tmpiteminfo)
If CoreApplication.MainView.CoreWindow.Dispatcher.HasThreadAccess Then
Await Task.Run(Function()
'Await Task.Delay(1000)
If evalprogress IsNot Nothing Then
'ReportProgress(4, Nothing)
evalprogress.Report(4)
evalprogress.Report(5)
End If
' tempCount += 1
Return 5
End Function)
ElseIf CoreApplication.MainView.CoreWindow.Dispatcher.HasThreadAccess = False Then
Await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, Function()
'Await Task.Delay(1000)
If evalprogress IsNot Nothing Then
evalprogress.Report(4)
evalprogress.Report(5)
End If
' tempCount += 1
Return 5
End Function)
End If
'evalprogress.Report(5)
' MsgBox("condition count:" + tmpiteminfo2.Count.ToString)
ElseIf item.Count > 1 And ManualEvaluation = False Then
'do nothing
ElseIf item.Count = 1 And ManualEvaluation = True Then
'change this code to perform manual evaluation on one item.
'tmpiteminfo.Add(item.Item(0))
End If
ReDim pricearr(item.Count)
If ManualEvaluation Then
If ran = False Then
Dim count As Integer
For Each d As ItemInfo In tmpiteminfo
count = count + 1
If ItemValidation.ContainsValidCharacters(d.name) And ItemValidation.IsDouble(d.price) Then
'decide whether to manually evaluate the item or automatically evaluate it.
Log("Item name: " + d.name + " price #: " + d.price.ToString)
Else
Log("Item: " + d.name + " has invalid characters in its name. It will not be evaluated. Please remove the invalid characters to have the item evaluated." + "The item price may not be an integer. please fix this too (if applicable)")
iteminfo1.name = d.name
iteminfo1.price = 0
iteminfo1.evaluationSource = d.evaluationSource
iteminfo1.damaged = "NO"
iteminfo1.aquisitiondate = "1/1/1111"
iteminfo1.itempicture = Nothing
' tmpnoteval.Add(iteminfo1)
tmpevalinfo.currentItem = iteminfo1.name
tmpevalinfo.evaluated = False
tmpevalinfo.evaluationcondition = d.itemcondition
itemevalresultarr.Add(tmpevalinfo)
' tmpnoteval.Add(iteminfo1)
notevaluatedcount += 1
End If
Select Case d.itemcondition
Case Is = ItemCondition.Broken
broken.Add(d.price)
Case Is = ItemCondition.LooksLikeNew
Lookslikenew.Add(d.price)
'MsgBox("Looks like new price:" + d.price.ToString)
Case Is = ItemCondition.SomewhatUsed
somewhatused.Add(d.price)
' MsgBox("Somewhat Used price:" + d.price.ToString)
Case Is = ItemCondition.SomeDamage
damaged.Add(d.price)
End Select
Next
ran = True
End If
Else
'Automatically evaluate item using different retailers i.e. Amazon, E-Bay, etc.
'use grabfromonlinesource multiple times to grab from each evaluation source used.
Dim tmpevalitem As Task(Of List(Of EvaluationInfo))
For i = 0 To item.Count - 1
'does once for each item
'need to split it into conditions inside of grabfromonlinesource
If ItemValidation.ContainsValidCharacters(item.Item(i).name) Then
' evalprogress = New Progress(Of Integer)(Function(value) InlineAssignHelper(value, a))
If CoreApplication.MainView.CoreWindow.Dispatcher.HasThreadAccess Then
Await Task.Run(Function()
'Await Task.Delay(1000)
If evalprogress IsNot Nothing Then
' ReportProgress(10, Nothing)
evalprogress.Report(10)
ReportProgress(10, Nothing)
End If
' tempCount += 1
Return 10
End Function)
ElseIf CoreApplication.MainView.CoreWindow.Dispatcher.HasThreadAccess = False Then
Await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, Function()
'Await Task.Delay(1000)
If evalprogress IsNot Nothing Then
evalprogress.Report(10)
End If
' tempCount += 1
Return 10
End Function)
End If
tmpevalitem = GrabFromOnlineSource(item.Item(i).name, item.Item(i).evaluationSource, New Progress(Of Integer)(Function(value) InlineAssignHelper(a, value)))
tmpevalitem.Wait()
If CoreApplication.MainView.CoreWindow.Dispatcher.HasThreadAccess Then
Await Task.Run(Function()
'Await Task.Delay(1000)
If evalprogress IsNot Nothing Then
' ReportProgress(70, Nothing)
evalprogress.Report(70)
End If
' tempCount += 1
Return 70
End Function)
ElseIf CoreApplication.MainView.CoreWindow.Dispatcher.HasThreadAccess = False Then
Await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, Function()
'Await Task.Delay(1000)
If evalprogress IsNot Nothing Then
'evalprogress.Report(70)
End If
' tempCount += 1
Return 70
End Function)
End If
' ItemValuation.tmpProgressIndicator.Report(60)
If tmpevalitem.Result IsNot Nothing Then
autoitem.AddRange(tmpevalitem.Result)
Else
Continue For
End If
Else
Dim tmpevalinfoauto As EvaluationInfo
tmpevalinfoauto.currentItem = item.Item(i).name
tmpevalinfoauto.evaluationcondition = item.Item(i).itemcondition
autoitem.Add(tmpevalinfoauto)
End If
Next i
autoitem.Add(Nothing) 'use nothing as an indicator of a new item.
End If
If ManualEvaluation Then
Dim done(4) As Boolean
done(0) = False
done(1) = False
done(2) = False
done(3) = False
'MsgBox("item information count: " + tmpiteminfo2.Count.ToString)
For f = 0 To tmpiteminfo2.Count - 1
'MsgBox(tmpiteminfo2.Item(f).evaluationSource)
Select Case tmpiteminfo2.Item(f).evaluationSource
Case Is = "Gamestop"
tmpevalinfo.valuationsourceid = 1
Case Is = "Amazon"
tmpevalinfo.valuationsourceid = 2
Case Is = "Ebay"
tmpevalinfo.valuationsourceid = 3
'add more sources here later
End Select
Select Case tmpiteminfo2.Item(f).itemcondition
Case Is = ItemCondition.Broken
'If done(0) = False Then
mode = pricefunctions.Mode(broken.ToArray)
max = pricefunctions.MaxValue(broken.ToArray)
min = pricefunctions.MinValue(broken.ToArray)
avg = pricefunctions.AveragePrice(broken.ToArray)
standarddev = pricefunctions.standarddeviation(broken.ToArray)
done(0) = True
' End If
Case Is = ItemCondition.LooksLikeNew
'If done(1) = False Then
mode = pricefunctions.Mode(Lookslikenew.ToArray)
max = pricefunctions.MaxValue(Lookslikenew.ToArray)
min = pricefunctions.MinValue(Lookslikenew.ToArray)
avg = pricefunctions.AveragePrice(Lookslikenew.ToArray)
standarddev = pricefunctions.standarddeviation(Lookslikenew.ToArray)
done(1) = True
' End If
Case Is = ItemCondition.SomeDamage
' If done(2) = False Then
mode = pricefunctions.Mode(damaged.ToArray)
max = pricefunctions.MaxValue(damaged.ToArray)
min = pricefunctions.MinValue(damaged.ToArray)
avg = pricefunctions.AveragePrice(damaged.ToArray)
standarddev = pricefunctions.standarddeviation(damaged.ToArray)
done(2) = True
' End If
Case Is = ItemCondition.SomewhatUsed
'If done(3) = False Then
mode = pricefunctions.Mode(somewhatused.ToArray)
max = pricefunctions.MaxValue(somewhatused.ToArray)
min = pricefunctions.MinValue(somewhatused.ToArray)
avg = pricefunctions.AveragePrice(somewhatused.ToArray)
standarddev = pricefunctions.standarddeviation(somewhatused.ToArray)
done(3) = True
' End If
End Select
'assign values to minimum price, maximum price, and the other prices.
If min > 0 Then
tmpevalinfo.MinimumPrice = min
End If
If mode > 0 Then
tmpevalinfo.ReoccuringPrice = mode
End If
If avg > 0 Then
tmpevalinfo.avgprice = avg
End If
If max > 0 Then
tmpevalinfo.MaximumPrice = max
End If
If standarddev > 0 Then 'And standarddev < 1 Then
tmpevalinfo.avgdeviation = standarddev
End If
min = 0
max = 0
mode = 0
avg = 0
tmpevalinfo.currentItem = tmpiteminfo2.Item(f).name
tmpevalinfo.evaluationcondition = tmpiteminfo2.Item(f).itemcondition
'MsgBox(tmpiteminfo2.Item(f).itemcondition)
tmpevalinfo.evaluated = True
itemevalresultarr.Add(tmpevalinfo)
Next f
'Dim iteminfoc As New ItemInformation
'For s = 0 To tmpiteminfo.Count - 1
' iteminfoc.itemsevaluate.Add(tmpiteminfo.Item(s).name)
' 'add other item information and change to iteminfo type once I get information to display correctly on findquote form
'Next s
Dim itemval As New ItemValuation
Dim tmpevalsource As New EvaluationSource
Using uie As New DataAccess.SQLiteDb
For h = 0 To tmpiteminfo.Count - 1
tmpevalsource.EvaluationSourceName = tmpiteminfo.Item(h).evaluationSource
tmpevalsource.EvaluationWebAddress = (From EvalWeb In uie.ValuationSources Where EvalWeb.ValuationSourceName = tmpevalsource.EvaluationSourceName Select EvalWeb).ToString
Await itemval.archiveitem(tmpiteminfo.Item(h).name, tmpiteminfo.Item(h).name, tmpevalsource)
Next
End Using
'delete all the evaluated items from the database for next evaluation
Await ClearEvalTable()
'return regular results
Return itemevalresultarr
Else
'return automated evaluation results
'results are archived as they are retrieved so delete data from the table below
'delete all the evaluated items from the database for next evaluation
Return autoitem
End If
End Function
Private Async Function GrabFromOnlineSource(itemname As String, WebsiteSource As String, progress As IProgress(Of Integer)) As Task(Of List(Of EvaluationInfo))
tmpevalitem = Await GrabFromOnlineSource(item.Item(i).name, item.Item(i).evaluationSource, New Progress(Of Integer)(Function(value) InlineAssignHelper(totalprogress, value))). 'replace totalprogress with the a integer I mentioned in the comments.
tmpevalitem.Wait()
tmpevalitem = GrabFromOnlineSource(item.Item(i).name, item.Item(i).evaluationSource, New Progress(Of IProgress(Of Integer))(Function(value) InlineAssignHelper(evalprogress, value)))
tmpevalitem.Wait()
Public Structure EvaluationInfo
Dim ReoccuringPrice As Double
Dim MinimumPrice As Double
Dim MaximumPrice As Double
Dim avgprice As Double
Dim avgdeviation As Double
Dim currentItem As String
Dim valuationsourceid As Integer
Dim evaluationcondition As ItemCondition 'i.e. used,new,broken enum
Dim evaluated As Boolean
End Structure
Public Structure ItemInfo
Public Property name As String
Public Property price As Double
Public Property damaged As String
Public Property aquisitiondate As Date
Public Property evaluationSource As String
Public Property itemcondition As ItemCondition
Public Property itempicture As Byte()
Public Property itemid As Integer
End Structure
最佳答案
您是否尝试将函数 GrabFromOnlineSource 中的一个变量声明为 byref 并传递给此方法。在 GrabFromOnlineSource 中的模式之后,您可以从主函数或任何其他地方观察此变量。
抱歉,我应该检查一下
方法 nr.2
那么为什么你不把这个过程包装在类里面,如果你想在 2 个任务中取得进展,你可以随时观察这个对象或添加事件以进行进度跟踪
Public Sub SomeMethod()
Dim Wrap1 As New WrapConteiner
Dim Wrap2 As New WrapConteiner
Wrap2.Sleep = 200
Dim Tasks(0 To 1) As Task
Tasks(0) = New Task(AddressOf Wrap1.AwaitedProcessAsync)
Tasks(1) = New Task(AddressOf Wrap2.AwaitedProcessAsync)
Tasks(0).Start()
Tasks(1).Start()
Do While (Tasks(0).Status = TaskStatus.Running Or Tasks(1).Status = TaskStatus.Running Or Tasks(0).Status = TaskStatus.WaitingToRun Or Tasks(1).Status = TaskStatus.WaitingToRun)
Task.WaitAll(Tasks, 10)
Debug.Print("Wrap1: " & Wrap1.Progress)
Debug.Print("Wrap2: " & Wrap2.Progress)
Loop
Debug.Print("B")
End Sub
Public Class WrapConteiner
Property Progress As Integer
Property Sleep As Integer = 100
Public Sub AwaitedProcessAsync()
Dim x As Integer
For x = 1 To 100
Me.Progress = x
Threading.Thread.Sleep(Sleep)
Next
End Sub
End Class
关于vb.net - 如何将进度报告从内部函数传递到主函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46676294/
@After public void afterScenario() { if (ScenarioManager.getScenario().isFailed()) {
我已将 BIRT 报告集成到 Grails 中并设计了一份报告。我的 grails 应用程序中有一个名为 startPeriod (仅限月份和年份)的参数,我想将其传递给 BIRT。然后 BIRT 调
我有一些 Oracle 报告 (.rdf),正在考虑将其转换为 BIRT 报告。有没有办法将 .rdf 文件转换为 BIRT 报告设计文件? 最佳答案 完全自动化的解决方案可能是不可能的。您可以部分自
当 gcc 4.1(使用 gcov)下一行: p = 新类; 报告为 100% 分支覆盖率 为什么? 因为启用了异常处理!!! 为了解决此问题,请指定: -fno-exceptions 在 g++
真的有好 免费 BugZilla 报告工具?我发现 Web 界面上的默认搜索选项太有限了。我最大的问题是缺少 Order By 选项(一次只有 1 个字段,可供选择的字段集非常有限)。我已经做了一些谷
是否可以在 CFMX7 上运行 ColdFusion Report builder 生成的报告? 更明确地说,是否可以将 CF7 中的报告生成引擎更改为 CF8? 最佳答案 我猜这可能很难做到。我记得
根据Lucintel发布的新市场报告,智能家居市场的未来看起来很有吸引力,在家用安全、家电、娱乐、照明、HVAC、医疗保健和厨房应用中将带来许多机遇。 由于COVID-19导致的全球经济衰退,
PHPCodeSniffer 是否生成 HTML 报告? 如果不是呢?怎么办? 目前,我可以运行 PHPCodeSniffer,但它只生成 XML 文件并在终端中显示结果。 如何在 phpunit 中
我在一个包中添加了一个简单的测试。 按照手册中的建议,我尝试让 PHPUnit 加载配置: phpunit -c /app phpunit.xml 看起来像这样:
我有两个从 csv 文件加载的数据框。基本上来自不同的环境但格式/列相似,它们的行/值可能有所不同。我想找到差异并在新的数据框中创建它们。两个数据框也将具有相同的顺序。我有 100 个要比较的文件。提
我想看看是否有办法通过 javadoc 在我的 junit 报告中包含“描述性文本”。 JUnit 4 似乎不像 TestNG 那样支持 @Test 注释的“描述”属性。 到目前为止,我所研究的只有一
我正在使用操作、 Controller 、servlet struts 框架编写 Excel 报告。该报告非常拥挤,已经有大约 10 个单独的查询。由于报告发生变化,我需要再添加大约 10 个查询。有
在放弃 Syleam 的 openerp jasper 模块后,我在 Nan Tic 的 jasper_reports 模块上苦苦挣扎。 它一直给我一个错误: File "C:\Program Fil
我希望创建一个简单的日历。每天由编码器生成条目计数并以日历样式查看。如一月、二月等。或按月显示全年。 database have date_added and encoder columns 我在将它
我必须为报告创建 MySQL 查询。 我有一个表history,它记录产品订单的状态更改。我有订单生命周期(订单流程)的以下状态:新、已确认、正在处理、已发货、已交付、已取消、已退回。订单不一定遵循此
如何将多个查询合并为一个? 例如: //Successful Sales: SELECT username, count(*) as TotalSales, sum(point) as Points
MySQL 优化技术的新手。请找到下面的 mysqltuner.pl 报告,并建议我应该更改 my.cnf 中的哪些变量以优化性能。 还有一个问题- 我无法在我的 my.cnf 中找到一些变量,例如
我想知道,我想将我的 Swing Worker 的某种形式的进度报告回主线程,以便我的界面可以使用随着进度增加而变化的标签进行更新,例如 checking 1/6... checking 2/6...
我正在尝试在“报告”>“销售”下运行 Magento Paypal 结算报告,但每次我尝试运行该报告时,我都会收到消息“由于配置为空,无法获取任何内容” 我查看了“系统”>“配置”>“销售”>“付款方
我想要一个工具来帮助创建 sql 查询(对于非 IT 人员),例如 dbforge。 我希望我们的非 IT 人员(例如运营)创建他们自己的 sql 查询。 我的第二个目标是让他们能够按需执行这些查询。
我是一名优秀的程序员,十分优秀!