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

  • SEARCH
  • Home
  • 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 8852987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:32:15+00:00 2026-06-14T13:32:15+00:00

I have the following problem: public class ListenThread : SocketInvoke { [DllImport(Ws2_32, CharSet =

  • 0

I have the following problem:

public class ListenThread : SocketInvoke
{
            [DllImport("Ws2_32", CharSet = CharSet.Auto)]
            public unsafe static extern UInt32 WSAWaitForMultipleEvents(UInt32 cEvents, IntPtr hEventObject,
            UInt32 fWaitAll, UInt32 dwTimeout, Boolean fAlertable);

            public void ListenConnections(NetSharedData data)
            {
                while (true)
                {
                    unsafe
                    {
                        if (WSAWaitForMultipleEvents((UInt32)1, data.signal, (UInt32)0, (UInt32)100, false) != WSA_WAIT_TIMEOUT)
                        {
                        }
                   }
             }
}

data.signal is a UInt32 how i can cast it to IntPtr?, i try:

IntPtr signal = (IntPtr)data.signal;

but it doesn’t work because i need a pointer to data.signal (UInt32) type and not the int value as an pointer, that will make a memory exception.

An C++ example of what i need:

int signal = 0;
int* psignal = &signal;
  • 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-14T13:32:17+00:00Added an answer on June 14, 2026 at 1:32 pm
    new IntPtr(data.signal);
    

    You are going to have problems on a 64-bit platform because data.signal is only hanging on to the lower 32-bits of an address. If NetSharedData is yours you should consider changing the type of signal to IntPtr.

    If you are trying to get an address to data.signal:

    new IntPtr(&data.signal);
    

    I’m not sure this would properly pin the object (to prevent the memory manager from relocating it), I would do the following:

    1) Change the PInvoke signature:

    public unsafe static extern UInt32 WSAWaitForMultipleEvents(UInt32 cEvents, 
           void* hEventObject, UInt32 fWaitAll, UInt32 dwTimeout, Boolean fAlertable);
    

    2) use fixed to pin the object

    fixed (void* s = &data.signal)
    {
        if (WSAWaitForMultipleEvents((UInt32)1, s, (UInt32)0, (UInt32)100, false) != WSA_WAIT_TIMEOUT)
        {
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

please help me with the following problem. i have a class, like public class
Let's say I have the following class structure (simplified from my real-world problem): Public
I have following problem with JPQL: One Class has three fields: public class Message{
Hello, I have the following problem: public class TestCombo extends JFrame{ public TestCombo() {
I have following problem: I have class public class HockeyActivity extends SimpleBaseGameActivity implements IOnSceneTouchListener,
I Have following problem: class Request<T> { private T sw; public Request() { //How
I have the following weird problem. My main activity looks like this: public class
I have a following problem I want to solve ellegantly: public interface IMyclass {
I have the following problem. I have this pretty class and now I want
I have following class in Java code: public class CHRTreeCreator extends IndexCreator { ...

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.