Results 1 to 6 of 6

Thread: Rising events from class library called from module

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2009
    Posts
    6

    Rising events from class library called from module

    Hi, I've the next problem.

    I've an app that starts to work from a module wich should load a form an do other things with a class library who raise an event an the form shoud cath it.

    The problem is that applicarion.run(frmMain) displays the form in the same thread the the code stops work while the form is open. And I need that the app works in this way because the user need to send files to the app using args and this avoid that the app init another instance of it (in other code) and update the form with the info when the event is raised.

    Please help :(

    Module
    vb.net Code:
    1. Module moMain
    2.  
    3.     Public my_Class As New ClassDll.clsMain
    4.  
    5.     Public Sub main()
    6.  
    7.         Application.Run(frmMain)
    8.         Debug.WriteLine("Form Loaded")
    9.  
    10.         my_Class.DoSomething()
    11.  
    12.     End Sub
    13.  
    14. End Module

    Class
    vb.net Code:
    1. Public Class clsMain
    2.  
    3.     Public Event EventRaise()
    4.  
    5.     Public Sub DoSomething()
    6.         RaiseEvent EventRaise()
    7.     End Sub
    8.  
    9. End Class

    Form
    vb.net Code:
    1. Public Class frmMain
    2.  
    3.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    4.         AddHandler my_Class.EventRaise, AddressOf raised_from_class
    5.     End Sub
    6.  
    7.     Public Sub raised_from_class()
    8.         MsgBox("event raised")
    9.     End Sub
    10.  
    11. End Class

    The code is also attached without compiled files.
    Attached Files Attached Files

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width