È quello che logicamente verrebbe da pensare anche a me, ma se tu inserisci un codice di questo genere:
Vedi nella label i numeri che scorrono tranquillamente. Sto facendo un po' di ricerche con ILDASM su come può funzionare una cosa del genere, e ho visto che all'atto pratico Refresh richiama Invalidate e Updatecodice:Private Sub Form1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Click For c As Integer = 1 To 10000 Label1.Text = c.ToString() Label1.Refresh() Next End Sub
Update a sua volta richiama l'API UpdateWindowcodice:.method public hidebysig newslot virtual instance void Refresh() cil managed { // Code size 14 (0xe) .maxstack 8 IL_0000: ldarg.0 IL_0001: ldc.i4.1 IL_0002: call instance void System.Windows.Forms.Control::Invalidate(bool) IL_0007: ldarg.0 IL_0008: call instance void System.Windows.Forms.Control::Update() IL_000d: ret } // end of method Control::Refresh
La MSDN a tal proposito dice questo:codice:.method public hidebysig instance void Update() cil managed { // Code size 29 (0x1d) .maxstack 8 IL_0000: ldarg.0 IL_0001: ldfld class System.Windows.Forms.Control/ControlNativeWindow System.Windows.Forms.Control::window IL_0006: ldarg.0 IL_0007: ldfld class System.Windows.Forms.Control/ControlNativeWindow System.Windows.Forms.Control::window IL_000c: callvirt instance native int System.Windows.Forms.NativeWindow::get_Handle() IL_0011: newobj instance void [mscorlib]System.Runtime.InteropServices.HandleRef::.ctor(object, native int) IL_0016: call bool System.Windows.Forms.SafeNativeMethods::UpdateWindow(valuetype [mscorlib]System.Runtime.InteropServices.HandleRef) IL_001b: pop IL_001c: ret } // end of method Control::Update
Che la parte evidenziata c'entri qualcosa con tutto questo? Qui c'è bisogno della conferma di qualcuno più esperto di me...The UpdateWindow function updates the client area of the specified window by sending a WM_PAINT message to the window if the window's update region is not empty. The function sends a WM_PAINT message directly to the window procedure of the specified window, bypassing the application queue. If the update region is empty, no message is sent.![]()

Rispondi quotando