Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8524749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T07:46:35+00:00 2026-06-11T07:46:35+00:00

i’ve asked a question before but sounds that i didn’t explain it in good

  • 0

i’ve asked a question before but sounds that i didn’t explain it in good way so here is the codes of the buggest part
class packet handler (receive information from packet and store them at x,y and there is struct which accept 2 ushort ref so once i define an object it change the value of the variables i send)

public class PacketHandler : GUI
    {
        GameUser role;
        public PacketHandler(GameUser who)
        {
            role = who;
        }
        ushort Actualx, Actualy;
        public PacketHandler(ref ushort x ,ref ushort y)
        {
            x = Actualx; y = Actualy;
        }
        public unsafe void HandleServer(byte[] data)
        {
.
.
.
                        case 10010:
                            {
                                if (BitConverter.ToUInt16(data, 8) == 1002)
                                {
                                    Actualx = BitConverter.ToUInt16(data, 24);
                                    Actualy = BitConverter.ToUInt16(data, 26);
                                }
                                break;
                            }

this get the value from packets , store them at actualx , actualy preparing to give them to any ushort ref come at the defining object parameter

here is other class

public class ClientBase
{
    GameUser role2;
    public ClientBase(GameUser role)
    {
        role2 = role;
        Thread T = new Thread(HuntThread) { Name = "Hunt Thread" };
        T.Start(this);
    }
.
.
.
    public void HuntThread(object Sender)
    {
        ClientBase Client = Sender as ClientBase;
        while (true)
        {
            Monster Target = GetNextkill();
            if (Target != null)
            {
                Thread.Sleep(1000);
                ProxyParadise.Network.Packets.PacketHandler getxandy = new ProxyParadise.Network.Packets.PacketHandler(ref X, ref Y);
                ProxyParadise.Network.Packets.PacketStructure ps = new ProxyParadise.Network.Packets.PacketStructure();
.
.
.

and the real problem is i find zero at x and y , when i trace it i find zero at actualx,actualy however im sure they got a value , so i think im doing something stupid

so all in all , if u can’t help me at this code or figure out what i mean then please tell me a proper way to get values from another class while using threading , thanks everyone , please some mod delete my old question , i rephrase it now in better way

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T07:46:36+00:00Added an answer on June 11, 2026 at 7:46 am

    Here we go:

        ushort Actualx, Actualy;
        public PacketHandler(ref ushort x ,ref ushort y)
        {
            x = Actualx; y = Actualy;
        }
    

    You are assigning the values from the fields (which are initially zero) to the parameters, rather than the values from the parameters to the fields:

        ushort Actualx, Actualy;
        public PacketHandler(ushort x , ushort y)
        {
            Actualx = x;
            Actualy = y
        }
    

    Note I removed the ref too; that would have had the nasty side-effect (in your original code) of wiping the by-ref variables you passed in, since the fields are zero initially.

    However, what you can’t do is store a “reference to a ushort” as a field. If you need that, the best thing to do is to drop the value onto a class, and refer to the object:

    class Foo {
        public ushort Value {get;set;}
    }
    

    then any number of callers can have references to the same Foo object, and therefore updating one is updating all. Frankly, your PacketHandler would already serve in place of this Foo; the trick would be for multiple pieces of code to have a reference to the handler, and get their .ActualX / .ActualY from the object.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
This could be a duplicate question, but I have no idea what search terms
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am doing a simple coin flipping experiment for class that involves flipping a
I know there's a lot of other questions out there that deal with this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.