Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / May 2005

Tip: Looking for answers? Try searching our database.

.net 2.0 -> "InvalidOperationException" at DebugTime

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Horst Klein - 27 May 2005 06:31 GMT
Mit dem Framework 2.0 habe ich ein Problem das ich vorher nicht hatte.
Oder es zumindest nicht festgestellt habe.

In my Application I show each seconnd the Time in a statusbar.
At runtim it works fine. If I want debug, fires an
"InvalidOperationException".
Is it my bug or a bug in VS2005 Beta2?

Here the code to reproduce it
Imports System.Globalization
Public Class Form1

Private m_DateTimer As New System.Timers.Timer
Private m_DateThread As Threading.Thread

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
m_DateThread = New Threading.Thread(AddressOf UpdateTime)
m_DateThread.Priority = Threading.ThreadPriority.Lowest
m_DateThread.Start()
End Sub

Private Sub RefreshDate(ByVal source As Object, ByVal e As
System.Timers.ElapsedEventArgs)
Me.Text = DateTime.Today.GetDateTimeFormats("d"c,
CultureInfo.CurrentUICulture)(0).ToString
End Sub

Private Sub UpdateTime()
AddHandler m_DateTimer.Elapsed, AddressOf RefreshDate
m_DateTimer.Interval = 1000
m_DateTimer.Enabled = True
End Sub

End Class
cody - 30 May 2005 15:54 GMT
Wasn das? Denglisch?

In VS2005 ist es nicht mehr zulässig das Anwendungen Methoden oder
Properties von Controls wie bei dir "Me.Text=" von einem anderen Thread als
dem GUI-Thread aufrufen. Aus Kompatibilitätsgründen wird die Exception
allerdings nur im Debugmodus ausgelöst. Du solltest also immer mit
BeginInvoke() die Aufrufe zum GUI-Thread marshallen.

> Mit dem Framework 2.0 habe ich ein Problem das ich vorher nicht hatte.
> Oder es zumindest nicht festgestellt habe.
[quoted text clipped - 31 lines]
>
> End Class

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.