Go Premium for a chance to win a PS4. Enter to Win

x
?
SolvedPrivate

SSIS 2008 C# Script task not producing expected outcome

Posted on 2014-03-06
2
Medium Priority
?
25 Views
Last Modified: 2016-02-10
Hi,
I have the following script
using System;
using System.Data;
using Microsoft.SqlServer.Dts.Runtime;
using System.Windows.Forms;
using System.IO;

namespace ST_07bc0354bae645e8bf2e65be651aeec0.csproj
{
    [System.AddIn.AddIn("ScriptMain", Version = "1.0", Publisher = "", Description = "")]
    public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
    {

        #region VSTA generated code
        enum ScriptResults
        {
            Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
            Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
        };
        #endregion


       public void Main()
        {
             
            // Create a new FileSystemWatcher and set its properties.
            FileSystemWatcher watcher = new FileSystemWatcher();

            //Watch for changes in the following directory
            watcher.Path = @"C:\Test\";

            /* Watch for changes in  LastWrite times in the  directory. */
            watcher.NotifyFilter = NotifyFilters.LastWrite;

         
            // Add event handlers.
              watcher.Changed += new FileSystemEventHandler(OnChanged);
  
          // Begin watching.
        watcher.EnableRaisingEvents = true;
        watcher.WaitForChanged(WatcherChangeTypes.All, 20000);
       

    }
       
            // Define the event handlers. 
    private static void OnChanged(object source, FileSystemEventArgs e)
    {
        // Specify what is done when a file is  created, 
             MessageBox.Show("Hello, File exists");
    }

        }
    }

Open in new window

which watches the specified folder for a specified time.
If a file is saved to the folder during the watch period, I expect the Message  in the event handler to display.
However, it is not displaying. The task waits for the specified time , the box remaining yellow
scripttaskwaiting.jpgafter the time has elapsed, it finishes, going to green…
FileSystemWatcherTask-suceeds.jpgbut no message box appears,
any guidance appreciated..
0
Comment
Question by:blossompark
2 Comments
 
LVL 40

Accepted Solution

by:
lcohan earned 1500 total points
ID: 39910578
That IS because that's exactly what is it coded for it to do - check that folder for "specified time." and "after the time has elapsed, it finishes, going to green"
0
 

Author Comment

by:blossompark
ID: 39911147
Hi lcohan,
thanks for your comment.
When I drop the file into the folder during the "watch" period should it not then trigger a call to the onChanged Event Handler which displays the message box?
0

Featured Post

[Webinar] Cloud Security

In this webinar you will learn:

-Why existing firewall and DMZ architectures are not suited for securing cloud applications
-How to make your enterprise “Cloud Ready”, and fix your aging DMZ architecture
-How to transform your enterprise and become a Cloud Enabler

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question