1) Create a new Script Task on the Map Pre Tasks section to Run before the map(Inside the Map-Tasks-Map Pre Tasks-Tasks that run before the map-Right Click and select New Task-Run Script) and name it SYNC_TASK like in the image below:
2) Now we will use the following script to start a process and ensure that the next step isn’t attempted until this task completes. In our example we will simply open notepad.exe and wait to move on until the product is closed. This same methodology could be applied to a stored procedure or SSIS package or even calling an external web service. The image below shows the example in VB.NET but you can use either.
Here is the script in both VB.NET and C# formats below:
‘Specify the location of the Notepad.exe file
Dim filename As String = “C:\Windows\System32\Notepad.exe”
‘Specify the parameters you want to run on the file
‘This example passes in one parameter that indicates which file it should open
Dim fileparameters As String = “file.txt”
‘This next step runs the file passing in the parameters
Dim process = System.Diagnostics.Process.Start(filename, fileparameters)
‘Do not proceed until the process is complete
‘In our example, wait until Notepad.exe is closed
//Specify the location of the Notepad.exe file
string filename = “C:\\Windows\\System32\\Notepad.exe”;
//Specify the parameters you want to run on the file
//This example passes in one parameter that indicates which file it should open
string fileparameters = “file.txt”;
//This next step runs the file passing in the parameters
System.Diagnostics.Process process = System.Diagnostics.Process.Start(filename, fileparameters);
//Do not proceed until the process is complete
//In our example, wait until Notepad.exe is closed
3) Run the Map by selecting the Run Map function on the Ribbon while your map is selected (this can also be done from inside the map by selecting Run when it is open).
4) In our scenario, the Notepad.exe program will launch and nothing else will continue with SmartConnect until we close the Notepad.exe application. Once Notepad is closed, the rest of the map will execute as planned.
As you can see in this simple example, we can ensure a task is finished by using standard .NET functionality.