473,394 Members | 1,746 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

ISynchronizeInvoke.Invoke call

What is wrong with my call below. If I change the
delegate and the CallBackComplete function to not take in
parameters then the .Invoke call works fine. As soon as I
put the parameters back I get "Parameter count mismatch."
error. Am I supposed to implement ISynchronizeInvoke in
order to call .Invoke? If so, why does it work when the
method i am trying to invoke has no parameters.

Private Delegate Sub CallbackCompleteDelegate(ByVal args()
As Object)

Private Sub SomeCallback(ByVal ACResult As IAsyncResult)
' calls .EndInvoke and does some async work

Dim Test As New CallbackCompleteDelegate(AddressOf
CallbackComplete)

Dim args(1) As Object
args(0) = "one"
args(1) = "two"

MainForm.Invoke(Test, args)
End Sub

Private Sub CallbackComplete(ByVal args() As Object)
' not even accessing the parameters

Debug.WriteLine("CallbackComplete - " &
AppDomain.GetCurrentThreadId)
End Sub
Nov 20 '05 #1
1 3061
Your delegate and CallbackComplete need to list out the
parameters and not take them in as an array. So...

Private Delegate Sub CallbackCompleteDelegate(ByVal one As
Object, ByVal two As Object)

Private Sub SomeCallback(ByVal ACResult As IAsyncResult)
' calls .EndInvoke and does some async work

Dim Test As New CallbackCompleteDelegate(AddressOf
CallbackComplete)

Dim args(1) As Object
args(0) = "one"
args(1) = "two"

MainForm.Invoke(Test, args)
End Sub

Private Sub CallbackComplete(ByVal one As Object, _
ByVal two As Object)
' not even accessing the parameters

Debug.WriteLine("CallbackComplete - " &
AppDomain.GetCurrentThreadId)
End Sub

Nov 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: GM | last post by:
Hi, My application has a need to cache a number of shared reference lists containing basic business objects. In order to improve performance these lists are fetched and updated in the...
0
by: Jedrzej Miadowicz | last post by:
I have a problem when using ISynchronizeInvoke.BeginInvoke with polymorphic parameters. It seems that if I try to call BeginInvoke and in the array of parameters place an object that's derived from...
2
by: Tom Dacon | last post by:
I'm raising an event in a component, using ISynchronizeInvoke.Invoke, and my event args object contains a string as one of its members. If the string is longer than 63 bytes, the Invoke call pulls...
1
by: Tim Murray | last post by:
Hi, I am creating a multithreaded server application in Managed C++. Each client that connects to the server will be running on their own thread to process their input. They all need to share...
0
by: Wavemaker | last post by:
One of the things I've struggled with from time to time is handling events raised on different threads. For example, an object could be listening to events from one or more objects running in...
4
by: jherl | last post by:
I am getting an "Object reference not set to an instance of an object" when I try to execute the Invoke method. I have it set up as follows: --- Private _syncObject As...
7
by: Jeff Stewart | last post by:
I need a thread to run a subroutine which updates my main form's progress bar. I've properly marshaled all UI updates to the main UI thread, and after the main thread starts the worker thread, it...
1
by: schaf | last post by:
Hi NG ! I set the CurrentCulture and the CurrentUICulture at the start of my app using this code: string sUICulture = System.Configuration.ConfigurationSettings.AppSettings; if (sUICulture !=...
2
by: =?Utf-8?B?a2VubmV0aG1Abm9zcGFtLm5vc3BhbQ==?= | last post by:
vs2005, c# Trying to understand why one way works but the other doesnt. I have not tried to create a simpler mdi/child/showdialog app for posting purposes (I think even this would not be so small...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.