2 Replies - 5097 Views - Last Post: 19 April 2013 - 10:18 PM

#1 Drowjam  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 33
  • Joined: 16-October 12

Class for handling object occuring at same time

Posted 19 April 2013 - 04:06 AM

My idea is simply this, Monitor two Objects, If they are called about the same time then raise event about said objects.
basically im trying to check and see if the two objects would be considered to have been used at the same time.

This Is what i have so far, most of my question are asked in the code.

its a generic so it dosent matter what the two objects are.

Public Class Time_Space(Of T, T2)
    'The two objects that are being Watched,before = before object is accessed, after = after object was accesed
    Private X_After, X_Before As T : Private Y_After, Y_Before As T2
    'IS THERE A BETTER WAY OF TIMING THE OBJECTS??????????
    'The time of when the object was accessed last
    Private LastAccess_X, LastAccess_Y As DateTime
    'DOES THIS METHOD WORK WELL OR SHOULD I CONSIDER A NEW APPROACH?????
    'The block of time that the two object check to see if they occur within
    Public Property Time_Block As Integer = 0
    Public Property X As T
        'CAN I GET MORE DETIALED INFORMATION ABOUT THE OBJECT AND WHAT HAPPENED WHEN IT WAS ACCESSED??????
        Get
            X_Before = X_After
            LastAccess_X = DateTime.Now
            Check_TimeBlock()
            Return X_After
        End Get
        Set(value As T)
            X_Before = X_After
            X_After = value
            LastAccess_X = DateTime.Now
            Check_TimeBlock()
        End Set
    End Property
    Public Property Y As T2
        Get
            X_Before = X_After
            LastAccess_Y = DateTime.Now
            Check_TimeBlock()
            Return Y_After
        End Get
        Set(value As T2)
            Y_Before = Y_After
            Y_After = value
            LastAccess_Y = DateTime.Now
            Check_TimeBlock()
        End Set
    End Property
    'WHAT IS A BETTER NAME???, AM I Forgeting any important Information??
    Public Event SameTimeBlock(ByVal X_Befor As T, ByVal X_After As T, ByVal Y_before As T2, ByVal Y_after As T2)
    Private Sub Check_TimeBlock()
        If Val_Func.Subtract_Pos(LastAccess_X.Millisecond, LastAccess_Y.Millisecond) <= Time_Block Then 'Returns an non-negative value 
            RaiseEvent SameTimeBlock(X_Before, X_After, Y_Before, Y_After)
        End If
    End Sub
End Class



well this all started when i was reading about programming padagriams<<<<F-YOU, Im not capable of making anything on a professional level but needless to say it gave me this idea and now im just looking for some advice on how to do it better or learn the technical concepts behind it so i can perform tedious research. Thanks again for anything you can offer. It is always appricaited

Is This A Good Question/Topic? 0
  • +

Replies To: Class for handling object occuring at same time

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9204
  • View blog
  • Posts: 34,582
  • Joined: 12-June 08

Re: Class for handling object occuring at same time

Posted 19 April 2013 - 09:32 AM

So.. let's step back. Exactly how are you going to use this?

I am certain you realize .NET is a pretty state based block of languages. Meaning the program executes (mostly in a vanilla setting) instructions line by line.. so trying to watch if two objects are 'used' (what, or how that is actually defined is another good question) becomes mood at the line level, right?

Just curious if I had more information I could suggest a better path.
Was This Post Helpful? 0
  • +
  • -

#3 Drowjam  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 33
  • Joined: 16-October 12

Re: Class for handling object occuring at same time

Posted 19 April 2013 - 10:18 PM

View Postmodi123_1, on 19 April 2013 - 09:32 AM, said:

So.. let's step back. Exactly how are you going to use this?

I am certain you realize .NET is a pretty state based block of languages. Meaning the program executes (mostly in a vanilla setting) instructions line by line.. so trying to watch if two objects are 'used' (what, or how that is actually defined is another good question) becomes mood at the line level, right?

Just curious if I had more information I could suggest a better path.


Ok so lets say objectA and ObjectB both affect each other. what im doing is seeing if there actions occur close enough together to be considered as occuring at the same time. this is to get around the fact that there will be proccessed 1 at a time. The Date time method was comprimise as i dont know how to check where and when a object was sent to the heap.

So lets give some cheap code
Public Class Test 
Dim withevents TimSpc as NEW Time_Space(Of Agent,Agent)(0,0)

Public Sub DUH()
TimSpc.X.Attack(TimSpc.y)
TImSpc.Y.Attack(Timspc.x)
'since both occur at about the same time i need to be able to consider the actions equal.
End Sub
Public sub TS_Equal(byval xA as Agent,Byval xB as Agent,Byval yA as Agent,Byval yB as Agent) Handles Timspc.SameTimeblock
'Revert both X and Y to origional condition. 
timspc.x = xB
timSpc.y = yA
'Then i would have some sort of tie breaker
end sub
End Class 


This is just a prototype and has alot of holes in it still. Im just wanting to figure out what i need to do to make it better. also sry as u can tell i have a talent for explaining things in a way people can understand.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1