Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
G

GrenMeera

@GrenMeera
About
Posts
5
Topics
2
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • My TextBox lacks discipline and Forms.Focus
    G GrenMeera

    Well, I finally discovered the problem. It was a side affect of the DataGrid being updated, and not the update itself. On an update, any changed data is sent to the TextBox and that part of the system was unaware to me. They were losing their focus because all objects were trying to refresh their data and not just the DataGrid. Also, the update to the DataGrid was being done through a DataTable, in which I never did need to refresh the DataSource variable. You simply have to:

    // Current Row
    DataRow row = _pumpTable.Rows[index];

    // Edit Pump
    row.BeginEdit();

    // Do Changes Here:

    row.EndEdit();

    // Accept Changes
    row.AcceptChanges();

    Thank you for your reply!

    C# help sysadmin

  • My TextBox lacks discipline and Forms.Focus
    G GrenMeera

    I am having some difficulty with a DataGrid object in my Forms application and could greatly use some advice/assistance. My DataGrid is receiving constant updates from a server application with changing data. This is reflected by changing the DataTable object that is set as it's DataGrid.DataSource. The problem is, however, that these refreshes seem to steal Focus from other Controls (TextBox, ComboBox) that are needed. At the moment, I have to repeatedly keep trying to hit a button and hope that I can finally land a OnButtonClicked event between refreshes for it to finally register. Now I have another application that is doing a very similar thing, but it does not have this problem. At first I noticed that the other application doesn't have the other buttons on the same Panel, but after trying to put my DataGrid inside it's own Panel, it's own TabPage, and even grouping my Buttons within a GroupBox, the Buttons and TextBox can't seem to keep focus for long enough to do anything. I've set my DataGrid to "TabStop = false" and even "CausesValidation = false", but these also did not help. The DataGrid became my all-seeing all-knowing master of Focus, and I am now it's slave. Here's a visual to help understand the layout and visualize the problem: Take a look![^] If anybody has any advice or help, it would be greatly appreciated! :)

    C# help sysadmin

  • Seriously silly sockets - please assist
    G GrenMeera

    Thank you for your reply. You were correct on both of your guesses. I do have an outstanding call to BeginReceive. My problem is that I don't know how to NOT have an outstanding call to BeginReceive. I was under the impression that Socket.Shutdown and Socket.Close were supposed to clear those. Also, yes I am using this application as a GUI. The form needs to update a DataGrid object fairly constantly in response to socket messages (which is causing a completely different bug that is frustrating me. heh. Am I the only one who misses MFC or Win32 GUI apps? ).

    C# csharp question help learning

  • Seriously silly sockets - please assist
    G GrenMeera

    Thank you for your reply. Tossing in some try {} catch {} makes the crash go away, although I do feel a little weird that every run of my application is throwing exceptions in the first place. If I must simply accept the exceptions as a normal operation, then perhaps I must. I also tried to toss some locks around the state objects on every use. This caused it to hang up inside of the Socket.Shutdown method. I was uncertain as to why exactly, as no breakpoints within any of the other locked locations were hit. Perhaps simply using a thread-safe static bool will be the way to go. I will let you know if this also helps. Thank you again for your advice! :)

    C# csharp question help learning

  • Seriously silly sockets - please assist
    G GrenMeera

    I have been having some difficulty in a C# application that uses a UDP socket connection. Everything works all sorts of fancy and fun until the closing of my Form application, and then I can't seem to stop receiving messages. I always get some form of exception inside of the receive callback stating that the socket is disposed. This is, of course, true. The problem is, why am I getting a message after I have closed down and shutdown the sockets? I'm not too familiar with every in and out of C# (don't think I'll ever get used to managed code. Can I have C back?) Included, I have the receive callback, which parses a message and continues to listen. I also included the CloseConnections method, which is called within the Form Closing event. Does Shutdown and Close not stop the messages from being received? If so, how can I so that the GC may dispose of my sockets without receiving a message afterwards? "An unhandled exception of type 'System.ObjectDisposedException' occurred in system.dll Additional information: Cannot access a disposed object named "System.Net.Sockets.Socket"."

    private static void ReceiveCallback(IAsyncResult ar)
    {
    // End Receive
    StateObject stateObject = (StateObject)ar.AsyncState;

    if(stateObject != null && stateObject.Socket != null && stateObject.DataBuffer != null && stateObject.EventMap != null)
    {
    	int bytesReceived = stateObject.Socket.EndReceive(ar);
    
    	if(bytesReceived > 0)
    	{
    		// Parse Data
    		SocketConnection.ParseReceiveBuffer(stateObject);
    	}
    }
    if(stateObject != null && stateObject.Socket != null && stateObject.DataBuffer != null && stateObject.EventMap != null)
    {
    	// Begin Receive
    	stateObject.Socket.BeginReceive(stateObject.DataBuffer, 0, stateObject.BufferSize, 0, new AsyncCallback(ReceiveCallback), stateObject);
    }
    

    }

    public void CloseConnections()
    {
    // Receive
    if(_recvSocket != null)
    {
    _recvSocket.Shutdown(SocketShutdown.Both);
    _recvSocket.Close();
    _recvSocket = null;
    _recvState.Socket = null;
    _recvState = null;
    }

    // Send
    if(\_sendSocket != null)
    {
    	\_sendSocket.Shutdown(SocketShutdown.Both);
    	\_sendSocket.Close();
    	\_sendSocket = null;
    	\_sendState.Socket = null;
    	\_sendState = null;
    }
    

    }

    C# csharp question help learning
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups