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

DTS + ExecuteInMainThread + Events in a winform...

Hi,

I create an application which create then execute a DTS package.
I want to fill a TreeView using the events generated by the DTS package
(onerror, onprogress....)

my code works fine except if I turn off the ExecuteInMainThread property
(ExecuteInMainThread = False)

In this case I can't fill my TreeView but I can send Console output texts.

I have try to use the delegation to invoke my functions which update the
treeview, but without success.

I'm using some code coming from this post:
http://groups.google.ca/groups?hl=en...languages.vb.*

and this one
http://groups.google.ca/groups?hl=en...ublic.dotnet.*

I have 4 methods: SetValue, SetError, SetStart, SetFinish
each one add a new node in the treeview
For example:
Friend Sub SetStart(ByVal source As String)

Dim oNode As TreeNode

Dim oNode2 As TreeNode

oNode = FindNodeByName(source)

If oNode Is Nothing Then

oNode = New TreeNode(String.Format("{0}", source))

oNode.Tag = source

oRootNode.Nodes.Add(oNode)

If bFirstExpand Then

oRootNode.Expand()

bFirstExpand = False

Application.DoEvents()

End If

End If

oNode2 = New TreeNode(String.Format("Start at: {0}", Now.ToString))

oNode.Nodes.Add(oNode2)

oNode.Expand()

End Sub
I have created a delegate object:
Public Delegate Sub SetStartDelegate(ByVal source As String)

Friend SetStartDel As SetStartDelegate = New SetStartDelegate(AddressOf
Me.SetStart)

In my OnStart DTS event I call this:

Overridable Overloads Sub OnStart(ByVal EventSource As String) _

Implements DTS.PackageEvents.OnStart

Console.WriteLine(" OnStart in {0}", EventSource)

Dim args() As Object = {EventSource}

frm.BeginInvoke(frm.SetStartDel, args)

'frm.SetStart(EventSource)

Application.DoEvents()

End Sub

but nothing appear. my SetStart method is called, but the code is locked at
this line:

oRootNode.Nodes.Add(oNode)

any guide?

thanks.

Jerome.


Nov 21 '05 #1
1 1499
after a lot of search in google I have found a sample code to help me, but
there is no more results:

Delegate Sub AddDelegate(ByVal node As System.Windows.Forms.TreeNode, ByVal
oParent As System.Windows.Forms.TreeNode)
Private Sub AddNode1(ByVal node As System.Windows.Forms.TreeNode, ByVal
oParent As System.Windows.Forms.TreeNode)

oParent.Nodes.Add(node)

End Sub

Private Sub AddNode(ByVal oNode As TreeNode, ByVal oParent As TreeNode)

If Me.InvokeRequired Then

TreeView1.Invoke(New AddDelegate(AddressOf AddNode1), New Object(1) {oNode,
oParent})

Else

oParent.Nodes.Add(oNode)

End If

End Sub

Friend Sub SetStart(ByVal source As String)

Dim oNode As TreeNode

Dim oNode2 As TreeNode

oNode = FindNodeByName(source)

If oNode Is Nothing Then

oNode = New TreeNode(String.Format("{0}", source))

oNode.Tag = source

'oRootNode.Nodes.Add(oNode)

AddNode(oNode, oRootNode)

If bFirstExpand Then

oRootNode.Expand()

bFirstExpand = False

Application.DoEvents()

End If

End If

oNode2 = New TreeNode(String.Format("Start at: {0}", Now.ToString))

AddNode(oNode2, oNode)

' oNode.Nodes.Add(oNode2)

oNode.Expand()

End Sub

The "AddNode" method detect if I need to use the invoke method or not, then
call the invoke or not.
during an "Invoke" call, the invoke lock my application. and never return,
also the delegated method is never called!!!

what is wrong?

"Jéjé" <willgart_A_@hotmail_A_.com> wrote in message
news:eA**************@tk2msftngp13.phx.gbl...
Hi,

I create an application which create then execute a DTS package.
I want to fill a TreeView using the events generated by the DTS package
(onerror, onprogress....)

my code works fine except if I turn off the ExecuteInMainThread property
(ExecuteInMainThread = False)

In this case I can't fill my TreeView but I can send Console output texts.

I have try to use the delegation to invoke my functions which update the
treeview, but without success.

I'm using some code coming from this post:
http://groups.google.ca/groups?hl=en...languages.vb.*

and this one
http://groups.google.ca/groups?hl=en...ublic.dotnet.*

I have 4 methods: SetValue, SetError, SetStart, SetFinish
each one add a new node in the treeview
For example:
Friend Sub SetStart(ByVal source As String)

Dim oNode As TreeNode

Dim oNode2 As TreeNode

oNode = FindNodeByName(source)

If oNode Is Nothing Then

oNode = New TreeNode(String.Format("{0}", source))

oNode.Tag = source

oRootNode.Nodes.Add(oNode)

If bFirstExpand Then

oRootNode.Expand()

bFirstExpand = False

Application.DoEvents()

End If

End If

oNode2 = New TreeNode(String.Format("Start at: {0}", Now.ToString))

oNode.Nodes.Add(oNode2)

oNode.Expand()

End Sub
I have created a delegate object:
Public Delegate Sub SetStartDelegate(ByVal source As String)

Friend SetStartDel As SetStartDelegate = New SetStartDelegate(AddressOf
Me.SetStart)

In my OnStart DTS event I call this:

Overridable Overloads Sub OnStart(ByVal EventSource As String) _

Implements DTS.PackageEvents.OnStart

Console.WriteLine(" OnStart in {0}", EventSource)

Dim args() As Object = {EventSource}

frm.BeginInvoke(frm.SetStartDel, args)

'frm.SetStart(EventSource)

Application.DoEvents()

End Sub

but nothing appear. my SetStart method is called, but the code is locked
at this line:

oRootNode.Nodes.Add(oNode)

any guide?

thanks.

Jerome.

Nov 21 '05 #2

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

Similar topics

1
by: Opa | last post by:
I have a synchronous socket dll which fires several events to a winforms client. The winform calls methods on the dll and the dll fires an event back on the same thread. I want the dll to fire...
2
by: Mark Broadbent | last post by:
Anyone know a simple place that i can reference which winform events are fired by other events (all of them)? I know the bog standard rules for the Load Activate etc, looking for a comprehensive...
2
by: dave | last post by:
Hi, I have a COM control / server I'm trying to get events from in my c# applications. 1) I'm trying to get events in both c# console apps and in c# winform apps. 2) I can call methods on the...
24
by: ej1002 | last post by:
Hi I have developed a Windows Application(C# Windows Form) which will get the IFrame Source of the page it is navigating using Webbrowser Control. Now I want do this in ASP.Net web application(C#...
4
by: Curious Coder | last post by:
I have been tasked with a project that I do not think can be accomplished. Our company has an application that runs as an unmanaged ActiveX control on user desktops. It is designed to work with...
20
by: David Levine | last post by:
I ran into a problem this morning with event accessor methods that appears to be a bug in C# and I am wondering if this a known issue. public event SomeDelegateSignature fooEvent; public event...
4
by: | last post by:
I'm looking to understand the way events work across multiple threads. I have an object that needs to process data as it comes in. When a certain threshold is hit, it needs to tell the host...
3
by: Hardy Wang | last post by:
Hi all, I am migrating a Windows Form application from .Net 1.1 to 2.0. I try to use BackgroundWorker object to handle a very lengthy process. I have a separated class to handle some very complex...
3
by: Jose Fernandez | last post by:
Hello. I would like to know how could i get all the subscriptions that my form has with the events of their controls. For example. I have a form with a textbox, a button and a dropdown. I...
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:
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: 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?
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
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,...

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.