Unable to use Property instead of Sub in Thread

  • Thread starter Thread starter Allen
  • Start date Start date
A

Allen

The code below appears in my thread code.

I'm unable to use WriteOnly Property because of signature unmatch.

WriteOnly Property ButtonAbortFolderVisible() As Boolean' does not have the
same signature as delegate 'Delegate Sub SetBooleanCallback(value As
Boolean)

Is there any way around that?

Thanks

Public Sub ButtonAbortFolderVisible(ByVal value As Boolean)

If mFormForAbort.ButtonAbortFolder.InvokeRequired Then

Dim d As New SetBooleanCallback(AddressOf ButtonAbortFolderVisible)

mFormForAbort.ButtonAbortFolder.Invoke(d, New Object() {value})

Else

mFormForAbort.ButtonAbortFolder.Visible = value

snip...

End If

End If

End Sub
 
Allen wrote:
I'm unable to use WriteOnly Property because of signature unmatch.

WriteOnly Property ButtonAbortFolderVisible() As Boolean' does not have the
same signature as delegate 'Delegate Sub SetBooleanCallback(value As
Boolean)

Is there any way around that?
<snip>

Unfortunately, nope. It seems to me that a Delegate can only be a
Function or a Sub.

If you want to expose a Property, then you may make it 'delegate' to
the actual method that aborts the folder:

Public WriteOnly Property ButtonAbortFolderVisible() As Boolean
Set(Value As Boolean)
DoAbortFolderVisible(Value)
End Set
End Property

Regards,

Branco.
 
thanks for the info


Branco Medeiros said:
Allen wrote:

<snip>

Unfortunately, nope. It seems to me that a Delegate can only be a
Function or a Sub.

If you want to expose a Property, then you may make it 'delegate' to
the actual method that aborts the folder:

Public WriteOnly Property ButtonAbortFolderVisible() As Boolean
Set(Value As Boolean)
DoAbortFolderVisible(Value)
End Set
End Property

Regards,

Branco.
 
Is the following correct?

SetBooleanCallback is a class (it is called a delegate only because classes
reference functions are called delegates)

from

Dim d As New SetBooleanCallback(AddressOf ButtonAbortFolderVisible)

d is an instance of that class that references ButtonAbortFolderVisible

I not sure of what I'm saying so if there is a better way to say it, it may
make it clearer.


Thanks again
 
Back
Top