DTS + ExecuteInMainThread + Events in a winform...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jéjé

    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 ExecuteInMainTh read property
    (ExecuteInMainT hread = 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:


    and this one


    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.Expan d()

    bFirstExpand = False

    Application.DoE vents()

    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 SetStartDelegat e(ByVal source As String)

    Friend SetStartDel As SetStartDelegat e = New SetStartDelegat e(AddressOf
    Me.SetStart)



    In my OnStart DTS event I call this:

    Overridable Overloads Sub OnStart(ByVal EventSource As String) _

    Implements DTS.PackageEven ts.OnStart

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

    Dim args() As Object = {EventSource}

    frm.BeginInvoke (frm.SetStartDe l, args)

    'frm.SetStart(E ventSource)

    Application.DoE vents()

    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.




  • Jéjé

    #2
    Re: DTS + ExecuteInMainTh read + Events in a winform...

    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(ByV al 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.A dd(node)

    End Sub

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

    If Me.InvokeRequir ed Then

    TreeView1.Invok e(New AddDelegate(Add ressOf AddNode1), New Object(1) {oNode,
    oParent})

    Else

    oParent.Nodes.A dd(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.Node s.Add(oNode)

    AddNode(oNode, oRootNode)

    If bFirstExpand Then

    oRootNode.Expan d()

    bFirstExpand = False

    Application.DoE vents()

    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_@ho tmail_A_.com> wrote in message
    news:eAjnHUpSFH A.2756@tk2msftn gp13.phx.gbl...[color=blue]
    > 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 ExecuteInMainTh read property
    > (ExecuteInMainT hread = 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.Expan d()
    >
    > bFirstExpand = False
    >
    > Application.DoE vents()
    >
    > 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 SetStartDelegat e(ByVal source As String)
    >
    > Friend SetStartDel As SetStartDelegat e = New SetStartDelegat e(AddressOf
    > Me.SetStart)
    >
    >
    >
    > In my OnStart DTS event I call this:
    >
    > Overridable Overloads Sub OnStart(ByVal EventSource As String) _
    >
    > Implements DTS.PackageEven ts.OnStart
    >
    > Console.WriteLi ne(" OnStart in {0}", EventSource)
    >
    > Dim args() As Object = {EventSource}
    >
    > frm.BeginInvoke (frm.SetStartDe l, args)
    >
    > 'frm.SetStart(E ventSource)
    >
    > Application.DoE vents()
    >
    > 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.
    >
    >
    >
    >[/color]


    Comment

    Working...