473,807 Members | 2,763 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

FileSystemWatch er - New Form Hanging

Hi,

I have a problem when I try to open a new form with the Changed event
(FileSystemWatc her) : the form hangs just after the paint. But I use the same
function (OpenFormPerfor m) to open a new form when I click on the Button1 and
it works fine. I think that it's a problem with thread or applicationCont ext.
I can use Application.Run (new Form) to put the new form in the message loop
but the application is suspended after the Application.Run () statement.

Thx for your help.

Public Class FrmPrinc
Inherits System.Windows. Forms.Form

#Region " Code généré par le Concepteur Windows Form "

Public Sub New()
MyBase.New()

'Cet appel est requis par le Concepteur Windows Form.
InitializeCompo nent()

'Ajoutez une initialisation quelconque après l'appel
InitializeCompo nent()

End Sub

'La méthode substituée Dispose du formulaire pour nettoyer la liste des
composants.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Disp ose()
End If
End If
MyBase.Dispose( disposing)
End Sub

'Requis par le Concepteur Windows Form
Private components As System.Componen tModel.IContain er

'REMARQUE : la procédure suivante est requise par le Concepteur Windows
Form
'Elle peut être modifiée en utilisant le Concepteur Windows Form.
'Ne la modifiez pas en utilisant l'éditeur de code.
Friend WithEvents Button1 As System.Windows. Forms.Button
<System.Diagnos tics.DebuggerSt epThrough()> Private Sub
InitializeCompo nent()
Me.Button1 = New System.Windows. Forms.Button
Me.SuspendLayou t()
'
'Button1
'
Me.Button1.Loca tion = New System.Drawing. Point(24, 32)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing. Size(88, 48)
Me.Button1.TabI ndex = 0
Me.Button1.Text = "Button1"
'
'FrmPrinc
'
Me.AutoScaleBas eSize = New System.Drawing. Size(5, 13)
Me.ClientSize = New System.Drawing. Size(292, 266)
Me.Controls.Add (Me.Button1)
Me.Name = "FrmPrinc"
Me.Text = "FrmPrinc"
Me.ResumeLayout (False)

End Sub

#End Region

Private WithEvents FSW As System.IO.FileS ystemWatcher
Private Delegate Sub OpenForm()

Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
OpenFormPerform ()
End Sub

Private Sub FrmPrinc_Load(B yVal sender As Object, ByVal e As
System.EventArg s) Handles MyBase.Load
FSW = New System.IO.FileS ystemWatcher
FSW.Path = Environment.Get EnvironmentVari able("USERPROFI LE")
FSW.NotifyFilte r = IO.NotifyFilter s.CreationTime Or
IO.NotifyFilter s.DirectoryName Or IO.NotifyFilter s.FileName Or
IO.NotifyFilter s.LastWrite
FSW.Filter = "BrowserIN. TXT"
FSW.EnableRaisi ngEvents = True
End Sub

Private Sub OpenFormPerform ()
Dim myForm As New Form
myForm.Controls .Add(New TextBox)
myForm.Show()
MessageBox.Show ("OK")
End Sub

Private Sub FSW_Changed(ByV al sender As Object, ByVal e As
System.IO.FileS ystemEventArgs) Handles FSW.Changed
OpenFormPerform ()
End Sub

End Class

Jan 30 '06 #1
1 2759
Any idea ?

"Frederic H" a écrit :
Hi,

I have a problem when I try to open a new form with the Changed event
(FileSystemWatc her) : the form hangs just after the paint. But I use the same
function (OpenFormPerfor m) to open a new form when I click on the Button1 and
it works fine. I think that it's a problem with thread or applicationCont ext.
I can use Application.Run (new Form) to put the new form in the message loop
but the application is suspended after the Application.Run () statement.

Thx for your help.

Public Class FrmPrinc
Inherits System.Windows. Forms.Form

#Region " Code généré par le Concepteur Windows Form "

Public Sub New()
MyBase.New()

'Cet appel est requis par le Concepteur Windows Form.
InitializeCompo nent()

'Ajoutez une initialisation quelconque après l'appel
InitializeCompo nent()

End Sub

'La méthode substituée Dispose du formulaire pour nettoyer la liste des
composants.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Disp ose()
End If
End If
MyBase.Dispose( disposing)
End Sub

'Requis par le Concepteur Windows Form
Private components As System.Componen tModel.IContain er

'REMARQUE : la procédure suivante est requise par le Concepteur Windows
Form
'Elle peut être modifiée en utilisant le Concepteur Windows Form.
'Ne la modifiez pas en utilisant l'éditeur de code.
Friend WithEvents Button1 As System.Windows. Forms.Button
<System.Diagnos tics.DebuggerSt epThrough()> Private Sub
InitializeCompo nent()
Me.Button1 = New System.Windows. Forms.Button
Me.SuspendLayou t()
'
'Button1
'
Me.Button1.Loca tion = New System.Drawing. Point(24, 32)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing. Size(88, 48)
Me.Button1.TabI ndex = 0
Me.Button1.Text = "Button1"
'
'FrmPrinc
'
Me.AutoScaleBas eSize = New System.Drawing. Size(5, 13)
Me.ClientSize = New System.Drawing. Size(292, 266)
Me.Controls.Add (Me.Button1)
Me.Name = "FrmPrinc"
Me.Text = "FrmPrinc"
Me.ResumeLayout (False)

End Sub

#End Region

Private WithEvents FSW As System.IO.FileS ystemWatcher
Private Delegate Sub OpenForm()

Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
OpenFormPerform ()
End Sub

Private Sub FrmPrinc_Load(B yVal sender As Object, ByVal e As
System.EventArg s) Handles MyBase.Load
FSW = New System.IO.FileS ystemWatcher
FSW.Path = Environment.Get EnvironmentVari able("USERPROFI LE")
FSW.NotifyFilte r = IO.NotifyFilter s.CreationTime Or
IO.NotifyFilter s.DirectoryName Or IO.NotifyFilter s.FileName Or
IO.NotifyFilter s.LastWrite
FSW.Filter = "BrowserIN. TXT"
FSW.EnableRaisi ngEvents = True
End Sub

Private Sub OpenFormPerform ()
Dim myForm As New Form
myForm.Controls .Add(New TextBox)
myForm.Show()
MessageBox.Show ("OK")
End Sub

Private Sub FSW_Changed(ByV al sender As Object, ByVal e As
System.IO.FileS ystemEventArgs) Handles FSW.Changed
OpenFormPerform ()
End Sub

End Class

Feb 2 '06 #2

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

Similar topics

2
4830
by: Paul | last post by:
Hi, I've been developing an application in VB.NET that uses the FileSystemWatcher and a popup notification in order to tell me when files have been downloaded. The FileSystemWatcher code in my project is basically the same one thats floating all over the VB.NET sites (by Jayesh Jain). The popup notification (called TaskbarNotifier) is a class originally by John O'Byrne written in C# and C++ but ported to VB.NET by Patrick Vanden...
2
2176
by: Sacha Korell | last post by:
I need to set up a FileSystemWatcher in my web application (to automatically process uploaded files) and I'm trying to decide where to set it up. I would like to keep it within the web app, but it needs to watch a certain folder even when nobody is making a request. I could instatiate the FileSystemWatcher in the Application_Start event, but what happens when somebody restarts the server? I guess in that case the FileSystemWatcher wouldn't...
20
4524
by: J-T | last post by:
We are working on an asp.net application which is a 3-tier application.I was aksed to create a component which monitors a folder and gets the file and pass them to a class library in our business logic layer(so far so good and easy).I initialize my class which is using a FileSystemWatcher in my Global.asax and everything works fine.I have found FileSystemWatcher class not very reliable and sometimes it behavies unexpectedly.I'm afriad that...
12
7463
by: ljh | last post by:
Has anyone else noticed that the FileSystemWatcher raises the changed event twice when a file is changed? Do you have any idea why this is the case?
1
2366
by: teslar91 | last post by:
I've been learning VB.NET for the past few weeks. One of the problems I've run into is difficulties updating controls in events from certain components, such as the FileSystemWatcher, that raise their events in different threads. I found plenty of examples on the Web of how to "detangle" the threads, using Delegate functions, .InvokeRequired, and .Invoke. But all of these examples demonstrated how to do it on a single form. I wanted...
4
4386
by: hooksie2 | last post by:
Hi, I am trying to use FileSystemWatcher to watch a log file which is written to via a 3rd party app and display the log in listbox on a form. The FileSystemWatch seems to work okay but I get the following error when I try to write to the listbox: "A first chance exception of type 'System.ArgumentNullException' occurred in System.Windows.Forms.dll"
15
4777
by: Angelo | last post by:
Hi all, I'm using a FileSystemWatcher to monitor a directory. I want the FSW to pop up my already instantiated but invisible form. However, I'm running into some problems with this. 1) In the FSW.Changed FileSystemEventhandler, I called the Show method 'frmMain.Show( )' on my form, the form appears but not completely painted and it appears to be hanging with the hourglass.
4
7758
by: Andrus | last post by:
To reporoduce, run the code. Observed: Form is shown Expected: message box should displayed. How to fix ? Andrus.
1
3162
by: Lila Godel | last post by:
My VB.NET 2008 application is setup with a Sub Main and no forms. At run time a NotifyIcon is created with one context menu choice (Close which terminates app). I have no trouble running the application and when I select Close from the icon's right click menu the system tray icon goes away and the application is removed from the listing on the processes tab of task manager. My problem is that the FileSystemWatcher event does not work....
0
9719
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9599
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10624
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10371
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10374
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7650
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5546
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4330
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3010
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.