
sgt_pinky
Avatar/Signature-
Posts
81 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by sgt_pinky
-
I seem to get very strange errors in VS 2005 when I am linking project files. Say in one solution I have a project with some classes, then I create a new project in that solution (usually a Winforms app to test my Windows Service), and add all the classes by using 'Add as link'. Strange things start to happen - like this one. Name 'E' is not declared!!!! ROFL :rolleyes:
-
Yeh, even though now in .NET 2.0 they have the IsNot keyword, I still use the old If Not Blah Is Nothing syntax because it has grown on me :-) kurf, you need to go back to school or something if you honestly believe that. Show me how to NOT program OO in VB.NET!!!!
-
LOL. Just solved it. Always the way. I have had this prob for 2 days, and I solve it immediately when I have just asked for help :S Initially my TcpListener was a Sub-level variable. Then I made it a Class-level variable and created a new Sub: Public Sub StopServer() thConnect.Abort() If Not Server Is Nothing Then Server.Stop() End Sub Ah dear. Thanks anyway ;-)
-
Hi, I have a multithreaded server app (Winforms) that I have converted to a service. It has a thread that simply creates a new TcpListener and waits for a connection: Public Sub StartListeningThread() Do Dim ip As IPAddress = IPAddress.Any Server = New TcpListener(ip, 4000) Server.Start() Dim tcpTmp As TcpClient = Server.AcceptTcpClient Dim tcpClient As New RUHTcpClient tcpClient.Client = tcpTmp.Client Server.Stop() Connections.Add(tcpClient) Loop End Sub This thread runs for the life of the application. The problem is that without using the command 'End', the application is blocking on this thread on the line: Dim tcpTmp As TcpClient = Server.AcceptTcpClient Server.AcceptTcpClient holds up everything. I have tried to Abort() the thread, etc, but that doesn't help. I can solve the problem using 'End' in the Winforms app, but in the service it causes all kinds of problems, and the program is left running in the taskmanager, even though it says 'Stopped' in the Services manager. TIA, Pinky
-
Firstly, thanks for your quick replies HJB417. Yep, I'm using TCP. I did a bit more research on the 'Flush()' method, and I found that it is 'Reserved for later use.' I actually fixed my problem though. I was brute force testing a multiple connection server with a little app I made to generate lots of clients. Each time I clicked the button it generated a client, AND added a handler for each client! So when I had added 3 clients, I was getting 3 lots of messages ;-) Oh well, the best problems are the ones with the simplest solutions I guess. Thanks again, Pinky
-
I have this problem when I am writing and reading network streams. If I send another packet, then it will also send the last packet again, so I end up sending more and more information. Somehow I mustn't be flushing the buffer out correctly or something. This is my output if I click a button 3 times - you can see by the third time it has sent the packet 3 times, and hence the server replies 3 times. To send a packet I am using: Dim ns As NetworkStream = Client.GetStream If ns.CanWrite Then Dim bytes() As Byte = Nothing bytes = System.Text.Encoding.UTF8.GetBytes(Msg) ns.Write(bytes, 0, bytes.Length) End If To receive a packet I am using: Dim ns As NetworkStream = cli.GetStream If ns.CanRead And ns.DataAvailable Then Dim bytes(cli.ReceiveBufferSize) As Byte ns.Read(bytes, 0, cli.ReceiveBufferSize) RaiseEvent NewPacket(cli, System.Text.Encoding.UTF8.GetString(bytes)) Else cli.Close() Connections.Remove(cli) RaiseEvent ClientMessage("Client connected from " & cli.Client.RemoteEndPoint.ToString.Split(":")(0) & " has disconnected.") End If I have tried closing the stream after I have finished writing, but that seems to destroy the socket. I have tried Flush() too, but not too sure how to use that one. Cheerio, Pinky
-
Cheers big ears, that's exactly what I wanted ;-) Thanks.
-
What is the best way to create an event that fires at 8am everyday? I have a method now that works, but I am sure it's not the best way. Maybe there is someway using API or something in .NET 2.0 that I am unaware of. TIA, Pinky
-
No. Most are dialogs, shown with frm.ShowDialog()
-
Hi, What is the correct way to do this. I have a windows forms app, and I want several of the forms to close when I press escape. So I have the general sub-routine in say 6 different forms, all with the same code: Private Sub CloseFormOnEscape(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles cmbSkin.KeyPress If Asc(e.KeyChar) = Keys.Escape Then Me.Close() End Sub In order to make my app more manageable, I could put the one subroutine in a general class, and just use AddHandler in the Form_Load() sub of each form. I was wondering if there was some better way that I could do it, using Inherits or something like that. This is a simple example, the actual code that I want to do this with is a class that is used to drag a skinned form, based on some specific controls. Cheers, Pinky
-
I wouldn't use a surface. I would use a texture with the flag 'Dynamic'. Then display the texture using a sprite. Are you loading the bitmaps from existing files or from some kind of I/O stream? Are the files already there? For example, 200 files already in one directory? In which case, you can buffer 10 or so into memory.
-
When you check your checkbox again, are you sure you are calling this subroutine again?
-
You have to be joking. Google, Google, GOOOOGGGLGLLEEEE!!!!@@!11111 arrrgghhh.. http://www.icsharpcode.net/OpenSource/SharpZipLib/Default.aspx
-
Yeah, I am going with the OCD diagnosis... Cool link Diesel, thanks.
-
I'm not sure why you would want to do this. That is exactly what the World Matrix is for. You lose performance, and also possibly the advantage of hardware acceleration for the vertex calculations (if you have a decent GFX card), if you open up the VB.
-
Hehe, this is my favourite page. It's called 'Hacker's Introduction to IL', but his first line is: "First of all, I'm not a hacker." Perhaps then, he should have titled the page, 'Introduction to IL'. Anyway, this page is great because this guy worked out everything himself. Good read, even if you never plan to learn IL to such a depth. http://csharpcomputing.com/Tutorials/Lesson2.htm
-
Well, thats just the nature of using a digital computer to solve mathematical problems, doesnt matter how long the mantissa is, it's just the fact that its finite. The reason that you get the correct answer on a calculator, but not if you do 64 bit floating point precision mathematics in a computer (Type Double in VB.NET), is actually due to the LACK of precision in the calculator, not BETTER precision in the calculator.
-
Your method is correct. The path to the image must be wrong.
-
That's great! This is the method I used: 1. Format a machine, install XP SP2 straight off CD. No .NET, no updates, nothing. 2. Install #Develop onto USB key on my dev machine. 3. Put the USB Key into the new XP SP2 machine. 4. Try and run SharpDevelop.exe. I get "Application failed to initalise properly.", plus some debug info. Ok, fair enough, no dotnetfx.exe, but I thought I would try anyway. Install the redistributable and #Develop works fine!! For those of you that haven't tried SharpDevelop, it's definitely worth a look. Has some interesting ideas that aren't present in the VS IDE. Plus, it's free. With SharpDevelop and the .NET redistributable you are coding legally, for free. Nice tip Bucky. :D
-
Hi, I have been making a game that uses TCP and UDP. For the UDP part it sends information such as player location, bullet information, and particle effects. I am having problems working out the best way to send the information over UDP. At the moment I am using the following 2 functions to convert a Structure to a Byte(), and vice versa. Public Function StructToBytes(ByVal InStruct As Object) As Byte() Dim Ptr As IntPtr = Marshal.AllocHGlobal(Marshal.SizeOf(InStruct)) Dim ByteArray(Marshal.SizeOf(InStruct) - 1) As Byte Marshal.StructureToPtr(InStruct, Ptr, False) Marshal.Copy(Ptr, ByteArray, 0, Marshal.SizeOf(InStruct)) Marshal.FreeHGlobal(Ptr) Return ByteArray End Function and, Public Function BytesToStruct(ByVal Buff() As Byte, ByVal MyType As System.Type) As Object Dim MyGC As GCHandle = GCHandle.Alloc(Buff, GCHandleType.Pinned) Dim Obj As Object = Marshal.PtrToStructure(MyGC.AddrOfPinnedObject, MyType) MyGC.Free() Return Obj End Function The problem is that ideally I want to have several different types of structure. Eg, a Structure that is only for updating a players position, or a Structure only for a particle effect. At the moment I only have one big structure, will all information in it, because I have to convert the structure at the other end, so I always know what type it is. If I have more than one type of structure, then I dont know the Type at the other end to convert it back from a byte array. Looking for some ideas if you have any. I was thinking of somehow using an Enum to specify the type of the structure, but not too sure. Cheers, Pinky
-
LOL, Diesel. Keep up with the attitude. Pretty soon noone will help you, or better yet, you will be banned. Next time you want to be a tool, think about the fact that you have asked a question to generous people that are willing to help you for free.
-
Here: http://www.xtremedotnettalk.com/showthread.php?p=448361#post448361 Third post from top. There is definitely a '\' in the text where it says c:setup.exe.
-
You don't need to use the API though, it's wrapped in the .NET Framework: Process.Start("c:\setup.exe") **EDIT** There is a bug in the [ vb ] tags that has removed my '\' after c: there. It's definitely there.
-
No, it's in the program. There is a specific module in DirectX that ignores hotkeys. If the programmer that wrote the game chooses to use this method, there is nothing you can do about it. ;)
-
You can use Array.Copy() to copy specific elements from one array to another. Not sure if that answers your question.