Some thread-safe methods for UI updates have the wrong number of arguments, and may result in runtime errors

Description

I encountered this when a plugin I was working on added a note to a sales order in reaction to an event on another thread - the CheckEditStatus() method of both the sales order form and the base JiwaApplication.Maintenance.Userinterface class had incorrectly passed parameters to the thread-safe delegate and this causes a runtime error.

I had to change JiwaApplication.Maintenance.Userinterface.CheckEditStatus from this:

Public Overridable Sub CheckEditStatus() Implements IJiwaForm.CheckEditStatus If Me.InvokeRequired Then Dim checkEditStatusThreadSafe As New CheckEditStatusThreadSafe(AddressOf CheckEditStatus) Me.Invoke(checkEditStatusThreadSafe, New Object()) Else If Not BusinessLogic Is Nothing Then If BusinessLogic.ChangeFlag = False Then SetToolBar(False) Else SetToolBar(True) End If End If End If End Sub

To this:

Public Overridable Sub CheckEditStatus() Implements IJiwaForm.CheckEditStatus If Me.InvokeRequired Then Dim checkEditStatusThreadSafe As New CheckEditStatusThreadSafe(AddressOf CheckEditStatus) Me.Invoke(checkEditStatusThreadSafe) Else If Not BusinessLogic Is Nothing Then If BusinessLogic.ChangeFlag = False Then SetToolBar(False) Else SetToolBar(True) End If End If End If End Sub

And similar to the sales order form as it overrode CheckEditStatus.

After a search I found the following places needed to be corrected:

  • JiwaApplication.Maintenance.Userinterface.CheckEditStatus

  • JiwaDashboardUI.CRM.ReadIndicatorData

  • JiwaDashboardUI.Generic.ReadIndicatorData

  • JiwaSalesUI.SalesOrder.BaseSalesOrderEntryForm.CheckEditStatus

  • Jiwa.MainForm.Manager_RequestToSetLoginStatusLabelBackColorToNormal

  • Jiwa.MainForm.Manager_RequestToSetLoginStatusLabelBackColorToRedCallback

  • Jiwa.MainForm.Manager_DatabaseSysDateTimeChanged

  • Jiwa.MainForm.Manager_MenuRead

Environment

None

Activity

Scott Pearce 6 May 2024 at 22:48

Fixed.

Done

Details

Assignee

Reporter

Components

Fix versions

Priority

Created 1 May 2024 at 05:02
Updated 9 May 2024 at 06:32
Resolved 6 May 2024 at 22:48