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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. In first time I draw, in the second, no.

In first time I draw, in the second, no.

Scheduled Pinned Locked Moved C#
graphicshelpquestionsysadminlearning
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Alex Cutovoi
    wrote on last edited by
    #1

    I have a question. I created a NavyBatlle with sockets that the client or server sends the coordinates to hit the opponent, drawing and "X" ou a "O". My problem is: In the first time the data is send for the server, the figure is drawn, on the second, appears the following runtime error: "Invalid parameter used". Wasn't the error appears since the beginning? Thanks a lot for who helps me. Below the problematic server's piece: Ah, I've implemented the IDsposable interface in my Draw class: private void DrawX(int iX, int iY, Graphics G) { using(G) { Pen pColor = new Pen(Color.Blue); pColor.Width = 5; Point pA = new Point(iX, iY); Point pB = new Point(iX+30, iY+30); Point pA1 = new Point(iX+30, iY); Point pB1 = new Point(iX, iY+30); G.DrawLine(pColor,pA,pB); //Nessa parte é que dá problema G.DrawLine(pColor,pA1,pB1); } } The part that I created the class and call the method to get the coordinates: do { sData = Reader.ReadString(); using(Draw Desenho = new Draw()) { Desenho.GetCoordinates(sData, G); } }while(DataStream != null && sData != "Close connection"); On client I just call the Write method of my BinayWriter to(of course) send data on the stream. One more time thanks a lot. :laugh:

    S 1 Reply Last reply
    0
    • A Alex Cutovoi

      I have a question. I created a NavyBatlle with sockets that the client or server sends the coordinates to hit the opponent, drawing and "X" ou a "O". My problem is: In the first time the data is send for the server, the figure is drawn, on the second, appears the following runtime error: "Invalid parameter used". Wasn't the error appears since the beginning? Thanks a lot for who helps me. Below the problematic server's piece: Ah, I've implemented the IDsposable interface in my Draw class: private void DrawX(int iX, int iY, Graphics G) { using(G) { Pen pColor = new Pen(Color.Blue); pColor.Width = 5; Point pA = new Point(iX, iY); Point pB = new Point(iX+30, iY+30); Point pA1 = new Point(iX+30, iY); Point pB1 = new Point(iX, iY+30); G.DrawLine(pColor,pA,pB); //Nessa parte é que dá problema G.DrawLine(pColor,pA1,pB1); } } The part that I created the class and call the method to get the coordinates: do { sData = Reader.ReadString(); using(Draw Desenho = new Draw()) { Desenho.GetCoordinates(sData, G); } }while(DataStream != null && sData != "Close connection"); On client I just call the Write method of my BinayWriter to(of course) send data on the stream. One more time thanks a lot. :laugh:

      S Offline
      S Offline
      Snowblind37
      wrote on last edited by
      #2

      I wonder if you need to refresh your connection after sending the first value stream. Or possibly re-set the object you are sending out. I have had problems before trying to re-send the same object that eventually gets corrupted. Hmmm, sorry no concrete answers but I suppose some possibilties to look at.

      A 1 Reply Last reply
      0
      • S Snowblind37

        I wonder if you need to refresh your connection after sending the first value stream. Or possibly re-set the object you are sending out. I have had problems before trying to re-send the same object that eventually gets corrupted. Hmmm, sorry no concrete answers but I suppose some possibilties to look at.

        A Offline
        A Offline
        Alex Cutovoi
        wrote on last edited by
        #3

        No, my connections are in threads. Talking about my object, I'm using the "using" keyword. I commented this part to see if was it that cause my problem but no. Man, I'don't know what I do. Am I answered your doubt? Thanks for help one more time

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

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