Threading.Task.Run 提交两次但仅在某些调用中提交

问题描述

朋友们:这个问题让我很困惑。

除非我记录它,否则此代码将提交相同的作业两次!

' optionally log to a textfile before call
If bLog Then LogProcess("Before run")

' this only processes once regardless of 
Executesql($"UPDATE [Process] SET [timesRepeated] += 1,[dateStarted] = '{Now}' WHERE [id] = {iID}")

Dim oBackground As New Background

' this thing spawns two of the some - but not all - jobs!
Dim t1 As Task = Task.Run(Sub() CallByName(oBackground,sProcessKey,CallType.Method,iID))

' optionally log to a textfile following call
If bLog Then LogProcess("After run")

这是作为内部计时器调用后台处理例程的一部分发生的。

我已经确认计时器只生成一次,并且每次“热节拍”只触发一次。

如果使用 bLog = True 调用此例程,我将得到单次执行。如果 bLog = False,则某些进程 (sProcessKey) 在完全相同的时间被调用两次。我也登录了这些例程。

有什么想法吗?

提前致谢。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)