posts - 315, comments - 268, trackbacks - 15

My Links

News

View Pietro Libro's profile on LinkedIn

DomusDotNet
   DomusDotNet

Pietro Libro

Tag Cloud

Article Categories

Archives

Post Categories

Blogs amici

Links

BackgroundWorker

There are 1 entries for the tag BackgroundWorker
Operazione cross-thread non valida...

Post nato da una discussione su forum. Se utilizziamo un componente Backgroundworker per l'esecuzione di codice in background, bisogna stare attenti alle operazioni "cross-thread", ad esempio quando il codice interagisce con i controlli di una Windows Form. Se abbiamo ad esempio un controllo ListView, per popolarlo senza provocare eccezioni durante l'esecuzione dell'applicazione, possiamo costruire ed utilizzare un delegate come nel codice seguente: Private Delegate Sub ScriviSuListViewDelegate()Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, _   ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork   If (Not (ListView1.InvokeRequired)) Then      For i As Integer = 0 To 20         ListView1.Items.Add(String.Format("Item #{0}",...

posted @ venerdì 1 febbraio 2008 13:51 | Feedback (1) | Filed Under [ Visual Basic .Net ]

Powered by:
Powered By Subtext Powered By ASP.NET