本文整理汇总了C#中IWavePlayer.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# IWavePlayer.Dispose方法的具体用法?C# IWavePlayer.Dispose怎么用?C# IWavePlayer.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IWavePlayer
的用法示例。
在下文中一共展示了IWavePlayer.Dispose方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
//.........这里部分代码省略.........
argMode = ArgMode.None;
}
else if (argMode == ArgMode.Token)
{
m_settingsModel.Token = arg.Trim();
argMode = ArgMode.None;
}
else if (argMode == ArgMode.Treshold)
{
var v = m_settingsModel.Treshold;
if (int.TryParse(arg, out v))
m_settingsModel.Treshold = v;
argMode = ArgMode.None;
}
else if (argMode == ArgMode.ArmedAlarm)
{
if (arg == "y" || arg == "yes" || arg == "t" || arg == "true")
m_settingsModel.ArmedAlarm = true;
else if (arg == "n" || arg == "no" || arg == "f" || arg == "false")
m_settingsModel.ArmedAlarm = false;
argMode = ArgMode.None;
}
else if (argMode == ArgMode.Silent)
{
if (arg == "y" || arg == "yes" || arg == "t" || arg == "true")
m_settingsModel.Silent = true;
else if (arg == "n" || arg == "no" || arg == "f" || arg == "false")
m_settingsModel.Silent = false;
argMode = ArgMode.None;
}
}
m_alarmIsArmed = m_settingsModel.ArmedAlarm;
Console.WriteLine("* Connection token: " + m_settingsModel.Token);
SpawnEyeListenerTask();
SpawnControllerListenerTask();
SpawnEyeProcessorTask();
SpawnControllerProcessorTask();
SpawnCommandsExecutorTask();
while (m_running)
{
var line = Console.ReadLine();
if (line == "exit")
m_running = false;
else if (line == "arm")
ArmAlarm();
else if (line == "disarm")
DisarmAlarm();
else if (line == "alarm-on")
StartAlarm();
else if (line == "alarm-off")
StopAlarm();
}
lock (m_commandsLock)
{
if (m_commandsQueue != null)
{
foreach (var command in m_commandsQueue)
command.PerformAction();
m_commandsQueue.Clear();
}
}
lock (m_eyeClientsLock)
{
if (m_eyeClients != null)
foreach (var eye in m_eyeClients)
eye.Value.Close();
}
lock (m_controllerClientsLock)
{
if (m_controllerClients != null)
foreach (var controller in m_controllerClients)
controller.Value.Client.Close();
}
while (true)
{
lock (m_lock)
{
if (m_eyeListener == null && m_controllerListener == null && m_eyeDataQueue == null && m_controllerDataQueue == null && m_commandsQueue == null)
break;
}
Thread.Sleep(10);
}
m_alarmIsPlaying = false;
lock (m_alarmLock)
{
m_waveOutDevice.Stop();
m_audioFileReader.Dispose();
m_audioFileReader = null;
m_waveOutDevice.Dispose();
m_waveOutDevice = null;
}
m_eyeClients = null;
m_controllerClients = null;
SaveSettings(m_settingsModel);
Thread.Sleep(1000);
}
示例2: ReleaseWavePlayer
// Stops and disposes of the wave player. Wave players created through
// the CreateWavePlayer method should be released by this method.
private void ReleaseWavePlayer(IWavePlayer player)
{
if (player != null)
{
player.Stop();
player.Dispose();
}
}
示例3: DisposeInternal
private void DisposeInternal(IWavePlayer player, WaveStream file)
{
new TaskFactory().StartNew(() => {
if(player != null) {
player.Dispose();
}
if(file != null) {
// Given that the NAudio framework gives no access to inner systems the best way to
// assure the player has been disposed before disposing the file is to wait a while
Task.Delay(1000).Wait();
file.Dispose();
}
});
}