views:

115

answers:

0

I have a browser enabled infopath form running within the XmlFormView control on a custom ASP.Net page in SharePoint.

The form needs to open a new browser window to perform some action and then act on a returned value from the browser window.

Currently using NotifyHost to tell the custom aspx page to render a window.open() javascript function.

However because I need to monitor for a return value from the seperate browser window (this is essentially creating a text file on a fileshare) I have to launch a FileSystemWatcher straight after the NotifyHost within the IP form.

Try

    Me.NotifyHost("Load")

Catch ex As Exception

    Throw New Exception("NotifyHost Failed")

End Try

FSW = New IO.FileSystemWatcher
With FSW

   .Path = "\\SERVER\Share$\"
   .EnableRaisingEvents = True

End With

AddHandler FSW.Created, AddressOf ItemLoaded

The problem is that when the FileSystemWatcher fires an event to indicate that a new document has been created in the fileshare this happens on a seperate worker thread (the filesystemwatcher is asynchronous.) InfoPath will not let me perform modifications to the XML file on a seperate thread and I cannot see how to return control to the main thread at this point and perform the action there.

Possible Options

  1. If I could call NotifyHost followed by the equivalent of the windows forms Application.DoEvents() then I could force the notification up to the custom aspx page and within the same method I could manually wait for the file to exist.

  2. Find a way to return control to the main thread when the FileSystemWatcher fires an event but specifiying a particular method to execute.

Some help with this would be great.

Thanks