473,799 Members | 3,147 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 2758
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
2175
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
4499
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
7462
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
4776
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
3160
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
9538
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
10247
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
10214
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,...
0
10023
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9067
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6803
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5459
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...
0
5583
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3751
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.