Ich habe eine App, die ich arbeite, die Verwendung von einem ISP abfragt (Download Quota). Ich habe versucht, dies über "new Thread (ThreaProc)" einzufädeln, aber das hat nicht funktioniert, jetzt versuche ich einen IAsyncResult-basierten Ansatz, der das gleiche tut ... Ich habe keine Ahnung, wie ich das korrigieren soll, bitte helfen?Label.Text = Struct.Value (Microsoft.VisualStudio.Debugger.Runtime.CrossThreadMessagingException)
Die need-to-know:
// Global
public delegate void AsyncPollData(ref POLLDATA pData);
// Class scope:
private POLLDATA pData;
private void UpdateUsage()
{
AsyncPollData PollDataProc = new AsyncPollData(frmMain.PollUsage);
IAsyncResult result = PollDataProc.BeginInvoke(ref pData,
new AsyncCallback(UpdateDone), PollDataProc);
}
public void UpdateDone(IAsyncResult ar)
{
AsyncPollData PollDataProc = (AsyncPollData)ar.AsyncState;
PollDataProc.EndInvoke(ref pData, ar);
// The Exception occurs here:
lblStatus.Text = pData.LastError;
}
public static void PollUsage(ref POLLDATA PData)
{
PData.LastError = "Some string";
return;
}
Das ist richtig, aber Sie könnten ein wenig erklären. – Machinarius