में Thread.Sleep का उपयोग मैं निम्नलिखितXamarin.Forms
MainPage = new ContentPage
{
Content = new StackLayout
{
Children =
{
new Button
{
Text = "Thread.Sleep",
Command = new Command(() =>
{
Thread.Sleep(1000);
MainPage.Animate("", x => MainPage.BackgroundColor = Color.FromRgb(x, x, x));
}),
},
new Button
{
Text = "Task.Run + Thread.Sleep",
Command = new Command(async() =>
{
await Task.Run(() => Thread.Sleep(1000));
MainPage.Animate("", x => MainPage.BackgroundColor = Color.FromRgb(x, x, x));
})
},
new Button
{
Text = "Device.StartTimer",
Command = new Command(() => Device.StartTimer(
TimeSpan.FromSeconds(1),
() =>
{
MainPage.Animate("", x => MainPage.BackgroundColor = Color.FromRgb(x, x, x));
return false;
})),
},
}
}
};
मैं System.Threading
और System.Threading.Tasks
शामिल निष्पादित करने के लिए चाहते हैं, लेकिन मैं अभी भी
नाम 'थ्रेड' में मौजूद नहीं है वर्तमान संदर्भ
This site पता चलता है कि Thread.Sleep
Xamarin.Forms
में इस्तेमाल किया जा सकता है। मेरे पास यह एक साझा परियोजना में है, पीसीएल नहीं।
'Thread.Sleep' से बचा जाना चाहिए (WinForms/WPF/Xamarin.Forms/सिल्वरलाइट/...) क्योंकि यह यूआई थ्रेड को फ्रीज करता है और यूआई को लटकता है। –
यह केवल प्रदर्शन उद्देश्यों के लिए है, लेकिन आपके अतिरिक्त के लिए धन्यवाद। – testing