473,408 Members | 2,813 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,408 software developers and data experts.

Custom event handlers and searching a listview

I am writting a program to manage DTS packages which is based on the code
example at the following link
http:\\www.support.microsoft.com/?kbid=319985.

I need to do things in a Windows Forms Application when various things occur
in the package so I have written some custom events to reraise the events
caught in the PackageEventsSink class.

I also have a listview in details mode with several columns, my problem is
that when I try and iterate through the listbox items when inside the event
handler for the StartPackage event the application hangs. Also when I do a
quickview on the listbox, when I expand the items object if I scroll down
through the list it hangs when I get to "expectingMouseUp", which is set to
false.

I have no idea what could be causing this, and it is *really* annoying
becuase the program is almost finished!

I hope someone can help

Cheers

Simon
Nov 15 '05 #1
5 3251

Hi Simon,

Does your "eventhandler for the StartPackage event" mean OnStart method of
DTS.PackageEvents?
What is your "expectingMouseUp"?
Normally, the WinForm UI hang is caused by the long-time IO operation in
the main thread, which blocks the refresh of the UI.
I think you should check in your code which manipulates the UI, do not do
synchronization operation with UI.
Also, you can invoke Invalidate method of the control to force it refresh.
I think a better design is manipulate the data operation in a seperate
worker thread, then use control.invoke or control.BeginInvoke.
The articles below talks about the design-pattern of mainpulate WinForm UI
in multiThread:
http://msdn.microsoft.com/msdnmag/is...g/default.aspx

Hope this helps,

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #2
Jeffrey,

Thanks for your reply. I have upload my code to
www.oursadlives.com\dts\ManagedDTS.cs and
www.oursadlives.com\dts\DeployToolDlg.cs. The important UI methods are
"PrepPackage()", "RunPackage()" and "PackageStarted(object sender,
PackageEventsSink.PackageEventArgs e)"

The PackageEventsSink.OnStart method raises a custom event OnPackageStart
which I have hooked into in the dialog class. It is in the handler for the
OnPackageStart event where I am having problems (everything works fine if I
don't try and do stuff with the listview as I output stuff to the console to
tell me what's going on) if I try and step through the code it never gets
into the loop it hangs on the foreach(...) statement. As for
expectingMouseUp, as far as I know this is just a property of
ListView.Items, all I have been able to verify is that if I expand Items in
watch, then I can scoll up and down fine unless I let
ListView.Items.expectingMouseUp appear in which case it causes Visual Studio
to hang until I kill the running app through taskmanager.

I have tried executing the DTS class in another thread and that doesn't
change anything. Also I have noticed that if I am looping through the
listview then I receive no more console messages after the OnStart call.

I have read the document that you posted a link to, perhaps I haven't
totally understood it yet but surely I can't do the work on the listview in
a separate thread becuase it was created on the UI thread?

I hope this better explains my situation.

Cheers

Simon

Does your "eventhandler for the StartPackage event" mean OnStart method of
DTS.PackageEvents?
What is your "expectingMouseUp"?
Normally, the WinForm UI hang is caused by the long-time IO operation in
the main thread, which blocks the refresh of the UI.
I think you should check in your code which manipulates the UI, do not do
synchronization operation with UI.
Also, you can invoke Invalidate method of the control to force it refresh.
I think a better design is manipulate the data operation in a seperate
worker thread, then use control.invoke or control.BeginInvoke.
The articles below talks about the design-pattern of mainpulate WinForm UI
in multiThread:
http://msdn.microsoft.com/msdnmag/is...g/default.aspx

Hope this helps,

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #3

Hi Simon,

Thanks for your feedback.
I found your problem strange. As you said, your application hangs at
"foreach(ListViewItem item in TasksListView.Items)", I think this statement
should work fine.
I think you should set a break point before this statement and in the
PackageStarted method, then in the debugger "watch window" watch if
TasksListView.Items collection is the correct value. Also, you can try to
invoke PackageStarted method in another method(such as button's click
event), if the problem still arise.
For the "expectingMouseUp", I have found it in debugger "watch window", I
think it is an internal field for .Net, I do now know why you care about
this field. Acutally, there is no document for the usage of this field.
For multiThreading modal, the listview is created in Main UI thread, but
you can expose a public method for the operation of listview, then in your
worker thread, you can use Control.BeginInvoke to execute this method from
worker thread. The method's execute is asynchronized.

Hope this helps,

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #4
Comments embedded below...
Thanks for your feedback.
I found your problem strange. As you said, your application hangs at
"foreach(ListViewItem item in TasksListView.Items)", I think this statement should work fine.
Good!
I think you should set a break point before this statement and in the
PackageStarted method, then in the debugger "watch window" watch if
TasksListView.Items collection is the correct value. Also, you can try to
invoke PackageStarted method in another method(such as button's click
event), if the problem still arise.
I'll try that
For the "expectingMouseUp", I have found it in debugger "watch window", I
think it is an internal field for .Net, I do now know why you care about
this field. Acutally, there is no document for the usage of this field.
I do not care about in the slightest I mentioned it only becuase it seemed
that Visual Studio crashed only when you try to and scroll past that field
in the debugger "watch window"
For multiThreading modal, the listview is created in Main UI thread, but
you can expose a public method for the operation of listview, then in your
worker thread, you can use Control.BeginInvoke to execute this method from
worker thread. The method's execute is asynchronized.


I'll do this and get back to you

Cheers Simon
Nov 15 '05 #5

Hi Simon,

If you have any further question, feel free to tell me, I will work with
you.
For "expectingMouseUp" in watch window, in my VS.net IDE, I can watch this
field, and its value is false, but when I view and scroll pass that value,
nothing special happens and the IDE will not crash.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #6

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

Similar topics

10
by: tony kulik | last post by:
This code works fine in ie and opera but not at all in Mozilla. Anybody got a clue as to how to get it right? <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <script...
1
by: Philip Townsend | last post by:
I have a user control that displays the contents of a shopping cart. I want this control to update its contents whenever an item is added to the cart. Currently, the cart only updates if it is...
7
by: Michael D. Ober | last post by:
Is there anyway to raise an event from a class and require that any program using that class (not just inheritance) have an event handler for specific events in the class? In my case, some events...
0
by: Mike Hofer | last post by:
I've noticed that some of my server-side event handlers are firing twice. I should point out that my web forms are derived from a custom base class that derives from System.Web.UI.Page. The...
16
by: Hamed | last post by:
Hello I am developing a utility to be reused in other programs. It I have an object of type Control (a TextBox, ComboBox, etc.) that other programmers use it in applications. they may set some...
14
by: Hamed | last post by:
Hello It seems that I should implement ICloneable to implement my own clone object. the critical point for me is to make a control object based on another control object that all of its event...
5
by: zlf | last post by:
I have an UserControl created by other component, its creator attachs some event handlers to MouseDoubleClick event, but I do not like those events to be triggered while it is db-clicked. I want to...
6
by: Arthur Dent | last post by:
Anyone know, in VB.NET (2005) how to prevent duplicate occurrences of the same event handler on an event? e.g... I have some object which raises an event, and some other class which consumes...
1
by: Phil Townsend | last post by:
I have an application that needs to respond to events that occur outside of the application itself. My project, called "ShowDetection" declares the event. I have a console app called "TestEvent"...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.