Új hozzászólás Aktív témák
-
x007
tag
Jaaaa, WPF-ben nincsen gyári DoEvents, viszont van workaround:
private void button1_Click(object sender, RoutedEventArgs e)
{
button1.IsEnabled = false;
WpfApplication.DoEvents();
Thread.Sleep(3000);
button1.IsEnabled = true;
}
/// <summary>
/// Designates a Windows Presentation Foundation application model with added functionalities.
/// </summary>
public class WpfApplication : Application
{
private static DispatcherOperationCallback exitFrameCallback = new
DispatcherOperationCallback(ExitFrame);
/// <summary>
/// Processes all UI messages currently in the message queue.
/// </summary>
public static void DoEvents()
{
// Create new nested message pump.
DispatcherFrame nestedFrame = new DispatcherFrame();
// Dispatch a callback to the current message queue, when getting called,
// this callback will end the nested message loop.
// note that the priority of this callback should be lower than the that of UI event messages.
DispatcherOperation exitOperation = Dispatcher.CurrentDispatcher.BeginInvoke(
DispatcherPriority.Background, exitFrameCallback, nestedFrame);
// pump the nested message loop, the nested message loop will
// immediately process the messages left inside the message queue.
Dispatcher.PushFrame(nestedFrame);
// If the "exitFrame" callback doesn't get finished, Abort it.
if (exitOperation.Status != DispatcherOperationStatus.Completed)
{
exitOperation.Abort();
}
}
private static Object ExitFrame(Object state)
{
DispatcherFrame frame = state as DispatcherFrame;
// Exit the nested message loop.
frame.Continue = false;
return null;
}
}Megjegyzem, hogy ez továbbra se fogja teljes mértékig megoldani a problémát, mert az ablak ugyanúgy meg fog fagyni a DB kapcsolat tesztelésekor. (WinForms esetén is így lenne) Szóval mindenképpen javaslom a BackGroundWorker használatát.
Új hozzászólás Aktív témák
● ha kódot szúrsz be, használd a PROGRAMKÓD formázási funkciót!
- Luck Dragon: Asszociációs játék. :)
- Philips LCD és LED TV-k
- Kínai és egyéb olcsó órák topikja
- Samsung Galaxy S25 Ultra - titán keret, acélos teljesítmény
- Autós topik
- Apple iPhone 17 - alap
- Apple Watch
- Gigabyte alaplap topik
- Milyen légkondit a lakásba?
- Kávé kezdőknek - amatőr koffeinisták anonim klubja
- További aktív témák...
- Playstation 5 lemezes - Gran Turismo 7, Tony Hawk's Pro Skater 1-2 eladó!
- ROG Ally (2023) RC71L + JSAUX HB1201S
- Vadonatúj, bontatlan iPhone AIR 256GB fekete és kék KÁRTYAFÜGGETLEN! 1 év Apple garancia!
- 3D nyomtatás kiváló minőségben / számlával / akár 9 színnel / széles anyagválaszték,
- HP,15.6",250 G6,8.gen.core i5 (8X4,0Ghz)8-32GB RAM,256GB-1TB SSD,nagyon jó akku,Win.11,szép
- Felsőkategóriás merev csöves Gamer PC-Számítógép! I9 11900K / RTX 3090 24GB / 64GB DDR4 / 1TB SSD
- HIBÁTLAN iPhone 15 Pro Max 256GB Black Titanium -1 ÉV GARANCIA - Kártyafüggetlen, MS3004
- Acer Nitro V 15 Laptop i5-13420H 8 GB RAM 512 GB SSD, RTX 4050 Dobozos, 3 ÉV GARANCIA
- Apple Mac mini M4 Pro 24GB RAM 512GB SSD 1 év garancia
- Bomba ár! Dell Latitude 5495 - Ryzen 5 I 8GB I 256SSD I 14" FHD I HDMI I Radeon I Cam I W10 I Gari
Állásajánlatok
Cég: Laptopműhely Bt.
Város: Budapest
Cég: PCMENTOR SZERVIZ KFT.
Város: Budapest