|
-
Dec 11th, 2013, 09:49 AM
#1
-
Dec 11th, 2013, 10:43 AM
#2
Re: Weird behaviour of variable scope using BackgroundWorker
When you say that the others are copies of picturebox properties, does the Get portion reference the control itself?
My usual boring signature: Nothing
 
-
Dec 11th, 2013, 10:50 AM
#3
Re: Weird behaviour of variable scope using BackgroundWorker
No,it doesn't
vb Code:
Public ReadOnly Property KartenHöhe_ As Integer Get Return Me.KartenHöhe End Get End Property
elsewhere, before the BackgroundWorker starts
vb Code:
KartenHöhe=PictureBox.Height
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
-
Dec 11th, 2013, 10:53 AM
#4
Re: Weird behaviour of variable scope using BackgroundWorker
What I was first thinking when I saw this was that this was the startup form, in which case it is probably the default instance. Default instances of forms are thread specific, which could be the cause of the problem. However, that would make more sense if NONE of the properties worked. That explanation doesn't explain why one of them works.
My usual boring signature: Nothing
 
-
Dec 11th, 2013, 11:15 AM
#5
Re: Weird behaviour of variable scope using BackgroundWorker
It is the StartUp Form. I woudn't even have asked if none of them had worked.
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
-
Dec 11th, 2013, 11:29 AM
#6
Re: Weird behaviour of variable scope using BackgroundWorker
I was thinking that maybe the types aren't thread safe, but Sytem.Int32 clearly is:
All members of this type are thread safe. Members that appear to modify instance state actually return a new instance initialized with the new value. As with any other type, reading and writing to a shared variable that contains an instance of this type must be protected by a lock to guarantee thread safety.
Have you tried setting the default instance of KartenHöhe ie-
Code:
Private KartenHöhe As Integer = -1
Public ReadOnly Property KartenHöhe_ As Integer
Get
Return Me.KartenHöhe
End Get
End Property
Instead of:
[code]
Code:
Private KartenHöhe As Integer
Public ReadOnly Property KartenHöhe_ As Integer
Get
Return Me.KartenHöhe
End Get
End Property
-
Dec 11th, 2013, 12:01 PM
#7
Re: Weird behaviour of variable scope using BackgroundWorker
Tried it, and the default values show. So it is not the default instance(which I am using) on which the properties are looking at. The one value which was "working", had a default value set and I didn't realise that. So all properties read show the same behaviour.
Thanks, for that.
BTW: I have already my workaround, as posted earlier. I was just interested in the reason.
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|