473,383 Members | 1,829 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,383 software developers and data experts.

Passing Parameters using Invoke in multi-threaded app

I'm having a problem with this code. I can't really understand why it
won't work if, for example, I pass in a linked list of 0 records.

Public Sub ConversionUpdateComplete(ByRef records As LinkedList(Of
ListViewItem))
If (Me.InvokeRequired) Then
Dim method As New MigrationCompleteEventHandler(AddressOf
ConversionUpdateComplete)
Me.Invoke(method, New Object() {records})
Else

lvUpdateSuggestions.Items.Clear()

For Each l As ListViewItem In records
lvUpdateSuggestions.Items.Add(l)
Next

lvUpdateSuggestions.View = True

pbConverting.Visible = False
lblConversionWait.Visible = False
lblSuggestionNotice.Visible = True
btnNext.Enabled = True
End If
End Sub

Jul 17 '07 #1
3 7167
Phillip Taylor <Ph*****************@gmail.comwrote in
news:11*********************@g12g2000prg.googlegro ups.com:
I'm having a problem with this code. I can't really understand why it
won't work if, for example, I pass in a linked list of 0 records.

In anycase, what is happening in your app?

You should use BeginInvoke instead. Invoke may deadlock your app under
load.
Public Sub ConversionUpdateComplete(ByRef records As LinkedList(Of
ListViewItem))
If (Me.InvokeRequired) Then
Dim method As New MigrationCompleteEventHandler(AddressOf
ConversionUpdateComplete)
Me.Invoke(method, New Object() {records})
Else

lvUpdateSuggestions.Items.Clear()

For Each l As ListViewItem In records
lvUpdateSuggestions.Items.Add(l)
Next

lvUpdateSuggestions.View = True

pbConverting.Visible = False
lblConversionWait.Visible = False
lblSuggestionNotice.Visible = True
btnNext.Enabled = True
End If
End Sub

Jul 17 '07 #2
"Phillip Taylor" <Ph*****************@gmail.comschrieb
I'm having a problem with this code. I can't really understand why
it won't work if, for example, I pass in a linked list of 0 records.
What does "won't work" mean? The code looks ok (although I don't know why
the arg is declared ByRef).
Public Sub ConversionUpdateComplete(ByRef records As
LinkedList(Of ListViewItem))
If (Me.InvokeRequired) Then
Dim method As New MigrationCompleteEventHandler(AddressOf
ConversionUpdateComplete)
Me.Invoke(method, New Object() {records})
Else

lvUpdateSuggestions.Items.Clear()

For Each l As ListViewItem In records
lvUpdateSuggestions.Items.Add(l)
Next

lvUpdateSuggestions.View = True

pbConverting.Visible = False
lblConversionWait.Visible = False
lblSuggestionNotice.Visible = True
btnNext.Enabled = True
End If
End Sub

Armin

Jul 17 '07 #3
I have seern lots of strange behavior of .net apps when used byref
parameters , as i also do not see the point why it should be passed byref in
this case , i recomend you to declare the parameter byval and try again it
might / or might not solve your problem :-)
Regards

Michel Posseth
"Armin Zingler" <az*******@freenet.deschreef in bericht
news:%2****************@TK2MSFTNGP02.phx.gbl...
"Phillip Taylor" <Ph*****************@gmail.comschrieb
>I'm having a problem with this code. I can't really understand why
it won't work if, for example, I pass in a linked list of 0 records.

What does "won't work" mean? The code looks ok (although I don't know why
the arg is declared ByRef).
> Public Sub ConversionUpdateComplete(ByRef records As
LinkedList(Of ListViewItem))
If (Me.InvokeRequired) Then
Dim method As New MigrationCompleteEventHandler(AddressOf
ConversionUpdateComplete)
Me.Invoke(method, New Object() {records})
Else

lvUpdateSuggestions.Items.Clear()

For Each l As ListViewItem In records
lvUpdateSuggestions.Items.Add(l)
Next

lvUpdateSuggestions.View = True

pbConverting.Visible = False
lblConversionWait.Visible = False
lblSuggestionNotice.Visible = True
btnNext.Enabled = True
End If
End Sub


Armin

Jul 17 '07 #4

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

Similar topics

2
by: Neil Fedin via .NET 247 | last post by:
I am writing a testing application that uses reflection to open assemblies and call methods. I have a function that looks like this... public void Method1 (int IDArray, bool SomethingElse){...
12
by: Joel | last post by:
Hi all, Forgive me if I've expressed the subject line ill. What I'm trying to do is to call a c++ function given the following: a. A function name. This would be used to fetch a list of...
7
by: Harolds | last post by:
The code below worked in VS 2003 & dotnet framework 1.1 but now in VS 2005 the pmID is evaluated to "" instead of what the value is set to: .... xmlItems.Document = pmXML // Add the pmID...
0
by: KK | last post by:
Hi MCPP gurus' I have a small problem in parameter passing.This is my situation namespace Abc { public __gc class ClassAbc { public: String* Hello(String* str) {
4
by: entitledX | last post by:
Hi, I'm trying to use the HDF library to read a few HDF files that I need to process. The data in each file varies in rows, but the columns remain constant. Because of that, I had dynamically...
2
by: John Lutz | last post by:
Our app is mainly COM based. We allow .NET plug-ins. When a plug-in is installed, it receives a COM pointer to the app. The plug-in implements our IExtensionImpl interface and gets the app...
17
by: =?Utf-8?B?U2hhcm9u?= | last post by:
Hi Gurus, I need to transfer a jagged array of byte by reference to unmanaged function, The unmanaged code should changed the values of the array, and when the unmanaged function returns I need...
3
by: ajaymohank | last post by:
hello everyone..... i am ajay and i am new to php. in my project i have an option to invoke a bat file by passing parrameters and to diplay the result. i tried this code but my page got hung or...
6
by: Andy Baker | last post by:
I am attempting to write a .NET wrapper for a C++ DLL file, but am having problems with passing strings as parameters. How should I be writing my C# function call when the C header file is...
10
by: vcquestions | last post by:
Hi. Is there way to have a function pointer to a delegate in c++/cli that would allow me to pass delegates with the same signatures as parameters to a method? I'm working with managed code. ...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.