|
-
Jul 7th, 2017, 03:08 PM
#1
Thread Starter
Addicted Member
Custom class varables & multi-threading
I have a problem (so true..)
I have a program that uses several threads to get things done (simple enough).
However I recently discovered how to create my own class variables (*cheer*). So I decided to re-code my program to use these new variables (and thus cut huge chunks of extra code out). my problem is this.. I have a variable (Client) being "set" with a "new" statement inside a secondary thread (the cues to create it come from another computer via a port listener, and that part works fine), but when i try to access this variable outside the thread it responds as "nothing". this didn't happen before with basic variables (strings, Boolean, integers, etc) so I can only assume that I'm missing something really obvious in my class creation.
Can someone point me to the solution?
Code:
Namespace CardData
Public Class Card
Public Property Suit() As CardSuit
Get
Return m_Suit
End Get
Set
m_Suit = Value
End Set
End Property
Private m_Suit As CardSuit
Public Property Value() As CardValue
Get
Return m_Value
End Get
Set
m_Value = Value
End Set
End Property
Private m_Value As CardValue
Public Property Score() As Integer
Get
Return m_Score
End Get
Set
m_Score = Value
End Set
End Property
Private m_Score As Integer
Public ReadOnly Property DisplayValue() As String
Get
Return Suit.ToString() + " " + Value.ToString()
End Get
End Property
End Class
Public Class Client
Public Property PlayerHand() As List(Of Card)
Get
Return m_PlayerHand
End Get
Set
If Value.Equals(m_PlayerHand) Then Return
m_PlayerHand = Value
If IsNothing(m_PlayerHand) Then Return
PopulatePlayerCards()
End Set
End Property
Private m_PlayerHand As New List(Of Card)
Public Property PlayerSent() As List(Of Card)
Get
Return m_PlayerSent
End Get
Set
m_PlayerSent = Value
End Set
End Property
Private m_PlayerSent As New List(Of Card)
Public Property HostHand() As Played
Get
Return m_HostHand
End Get
Set
If Value.Equals(m_HostHand) Then Return
m_HostHand = Value
Client_Window.PopulateHostCards()
End Set
End Property
Private m_HostHand As New Played
Public Property Myturn As Boolean
Get
Return m_Myturn
End Get
Set
m_Myturn = Value
End Set
End Property
Private m_Myturn As Boolean = False
Public Property IPlayed As Boolean
Get
Return m_IPlayed
End Get
Set
m_IPlayed = Value
End Set
End Property
Private m_IPlayed As Boolean = False
Public Property Trade_Received As Boolean
Get
Return m_Trade_Received
End Get
Set
m_Trade_Received = Value
End Set
End Property
Private m_Trade_Received As Boolean = False
Private Sub SortHand()
Me.PlayerHand = PlayerHand.OrderBy(Function(x) x.Suit).ThenBy(Function(x) x.Value).ToList()
End Sub
Public Sub ShowHand()
SortHand()
For Each card In PlayerHand
Debug.Print([Enum].GetName(GetType(CardSuit), card.Suit) + " " + [Enum].GetName(GetType(CardValue), card.Value) + " ")
Next
End Sub
End Class
Public Class Played
Public Property Type() As HandType
Get
Return m_Type
End Get
Set
m_Type = Value
End Set
End Property
Private m_Type As HandType
Public Property Cards() As List(Of Card)
Get
Return m_Cards
End Get
Set
m_Cards = Value
End Set
End Property
Private m_Cards As List(Of Card)
Sub New(Optional CardList As List(Of Card) = Nothing, Optional HType As HandType = Nothing)
m_Type = HType
m_Cards = CardList
End Sub
End Class
End Namespace
Tags for this Thread
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
|