Jump to content
Xtreme .Net Talk

Recommended Posts

  • *Experts*
Posted

I've got a splash screen as a seperate program which loads a very large main program. The main program takes different times to load depending of the user's file size, if the dotnet framework has been prior loaded, etc. I thought that I could create a file "Loaded.tmp" with the loading of the main program. The splash screen would then see the creation of "Loaded.tmp" and close.

 

What I have so far is not working so well and I could use some help.

 

In the splash screen load sub...

       With FileSystemWatcher1
           .EnableRaisingEvents = True
           .Path = Application.StartupPath
           .Filter = "Loaded.tmp"
           .NotifyFilter = NotifyFilters.LastWrite _
                           Or NotifyFilters.CreationTime _
                           Or NotifyFilters.LastAccess
       End With
       AddHandler FileSystemWatcher1.Created, AddressOf FileSystemWatcher1_Created

then - it seems this sub never gets executed

   Private Sub FileSystemWatcher1_Created(ByVal sender As System.Object, ByVal e As System.IO.FileSystemEventArgs) Handles _
   FileSystemWatcher1.Created

       If e.ChangeType = WatcherChangeTypes.Created Then
           File.Delete(Application.StartupPath & "Loaded.tmp")
           tmrProgressBar.Enabled = False
           Me.Close()
       End If
   End Sub

 

tmrProgressBar advances a progress bar.

 

Thanks Dan

Member, in good standing, of the elite fraternity of mentally challenged programmers.

 

Dolphins Software

Posted

hey dan here's some c# code of mine that might help....

InitializeComponent();
		this._watcher.Created += new System.IO.FileSystemEventHandler(this._watcher_Created);
		this._watcher.Changed += new System.IO.FileSystemEventHandler(this._watcher_Changed);
		this._watcher.IncludeSubdirectories = true;
		this._watcher.EnableRaisingEvents = true;

 

let me know if it helps

i'm not lazy i'm just resting before i get tired.
  • *Experts*
Posted

Hi Brandon, nice to hear from you again!!

 

I see what you did, but I'm have a problem converting this into VB lingo.

 

Me.FileSystemWatcher1.Created = New System.IO.FileSystemEventHandler(Me.FileSystemWatcher1_Created) produces a pretty nice error.

 

Dan

Member, in good standing, of the elite fraternity of mentally challenged programmers.

 

Dolphins Software

  • Administrators
Posted

in vb you can either use the handles clause

   Private Sub FileSystemWatcher1_Changed(ByVal sender As System.Object, ByVal e As System.IO.FileSystemEventArgs) Handles FileSystemWatcher1.Changed

   End Sub

 

or the addhandler keyword

   Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
       AddHandler FileSystemWatcher1.Changed, AddressOf FileSystemWatcher1_Changed
   End Sub

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

  • *Experts*
Posted

Thanks Plausibly Damp,

 

I tried that too with equally dismal results...and after doing some more research found that FileSystemWatcher is not very reliable and is not supported by Windows 98 and ME. So I decided to solve this problem differently and close the splash screen from the main program with reliable, Windows 98 & ME safe code.

 

   Private Sub Kill_SplashScreen()
       Dim myProcess As Process
       Dim myProcesses() As Process = Process.GetProcesses()
       For Each myProcess In myProcesses
           If myProcess.ProcessName = "SplashScreen" Then
               myProcess.Kill()
               Exit For
           End If
       Next
   End Sub

 

works perfectly!

 

Thanks

Dan

Member, in good standing, of the elite fraternity of mentally challenged programmers.

 

Dolphins Software

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...