SoundEffectInstance alarmSound = PlaySound(@"Alarms/"+alarmSoundString);
VibrateController vibrate = VibrateController.Default;
var vibrationLength = 1000;
var startTime = DateTime.Now;
vibrate.Start(new TimeSpan(0,0,0,0,vibrationLength));
MessageBoxResult alarmBox = MessageBox.Show("Press OK to stop alarm", "Timer Finished", MessageBoxButton.OK);
var ok = false;
While (!ok){
if (alarmBox == MessageBoxResult.OK)
{
ok = true;
}
else{
if(startTime.AddMilliseconds(vibrationLength * 1.2) < DateTime.Now)
{
startTime = DateTimne.Now;
vibrate.Start(new TimeSpan(0,0,0,0,vibrationLength));
}
}
}
alarmSound.Stop();
vibrate.Stop();
मोटे तौर पर
मैं विंडोज फोन के लिए कोड लिखने नहीं है इसलिए यह फोन अनुत्तरदायी बनने के लिए कारण हो सकता है। लेकिन सामान्य आइडिया यह देखने के लिए जांच कर रहा है कि क्या उपयोगकर्ता ठीक से मारा गया है और यदि नहीं, तो पर्याप्त कंपन ने एक नया शुरू करने के बाद पर्याप्त समय बिताया है।
यदि आप इसे पल्स करना चाहते हैं तो मैं AddMilliseconds का उपयोग करने का सुझाव दूंगा और अपनी इच्छित नाड़ी की लंबाई से अधिक लंबाई जोड़ूंगा।
एक टाइमर के बजाय
का उपयोग करके आप वर्ग नाटक इस
public class buzzz
{
MessageBoxResult alarmBox;
DispatchTimer alarmTimer = new DispatchTimer();
var vibrationLength = 1000.0;
var timerIncrease = 1.2;
VibrateController vibrate = VibrateController.Default;
public buzz()
{
alarmTimer.Interval = TimeSpan.FromMillseconds(vibrationLegnth * timerIncrease);
alarmTimer.Tick += alarmTimer_Tick
}
public void startBuzz()
{
SoundEffectInstance alarmSound = PlaySound(@"Alarms/"+alarmSoundString);
vibrate.Start(new TimeSpan(0,0,0,0,vibrationLength));
alarmTimer.Start();
alarmBox = MessageBox.Show("Press OK to stop alarm", "Timer Finished", MessageBoxButton.OK);
}
void alarmTimer_Tick(object sender, EventArgs e)
{
if(alarmBox == MessageBoxResult.OK)
{
alarmTimer.Stop();
vibrate.Stop();
}
else
{
vibrate.Start(new TimeSpan(0,0,0,0,vibrationLength));
}
}
}
को साफ आप इसे लगातार कंपन, या पल्स करना चाहते हैं चाहते हो सकता है? – Joe
@ जो मैं इसे – Chris
पल्स करना चाहता हूं, आपको समय के बाद समय निकालना सुनिश्चित करना चाहिए, अन्यथा आप किसी ऐसे व्यक्ति के लिए बैटरी निकालने का जोखिम उठा सकते हैं जो अपने फोन को किसी अन्य कमरे में छोड़ देता है। –