Amitava's Blog on Windows Vista: Application Certification and Compatibility
Test Case 8: Verify application launches and executes properly using Fast User Switching (Req.1.8)
Question: Sound is heard from another user’s session for my application on fast user switching. Can it stop automatically?
Answer: You need to manually stop the sound started playing in a user session once he switches. You can create an event handler to trap SessionSwitchReason.ConsoleDisconnect in.SessionSwitch event.
// Event handler to trap Switch User
private void SessionSwitchEvent(object sender, SessionSwitchEventArgs e)
{
if (e.Reason == SessionSwitchReason.ConsoleDisconnect) //Console Disconnected (switched user)
audio.Stop(); //Stop the audio object
}
else
if (e.Reason == SessionSwitchReason.ConsoleConnect) //Console Connected
audio.Play(strMediafilePath); //Play the audio file again
Add the event handler method to the SessionSwitch event appropriately.
private void Form1_Load(object sender, EventArgs e)
SystemEvents.SessionSwitch += new SessionSwitchEventHandler(SessionSwitchEvent); //Add the SessionSwitch EventHandler
…