DTS + ExecuteInMainThread + Events in a winform...


J

Jéjé

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&lr=&threadm=OTY49t3tCHA.2304@TK2MSFTNGP12&rnum=5&prev=/groups?hl=en&lr=&q=UCOMIConnectionPointContainer&meta=group%3Dmicrosoft.public.dotnet.languages.vb.*

and this one
http://groups.google.ca/groups?hl=en&lr=&threadm=ca6f01c284b9$a02a7b30$3bef2ecf@TKMSFTNGXA10&rnum=1&prev=/groups?hl=en&lr=&q=DTS+UCOMIConnectionPointContainer&meta=group%3Dmicrosoft.public.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.
 
Ad

Advertisements

J

Jéjé

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

DTS Event Handlers 1
DTS 1
dts and vb.net 1
DTS and VB.NET 2
Validation and cancelling click events in WinForms 6
DTS Generates an error 0
Only Columns DataGrid Winform Click Event ? 1
Executing a DTS package 2

Top