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
  1. Home
  2. General Programming
  3. C#
  4. Need help with threading

Need help with threading

Scheduled Pinned Locked Moved C#
helpcsharpvisual-studiographicsdesign
2 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.
  • Y Offline
    Y Offline
    Yannielsen
    wrote on last edited by
    #1

    Hi im new at these forums, so this is my first post, i hope that some of you guys could help me out with this problem i have. I'm building a drag n' drop program that will allow a user to drag n drop an item (like a button) from one control to another. Currently i have a problem managing threads, or rather parsing data between them. My problem is this. I need to sample the mouse's x and y coordinates for each control so that it will drop the item at the correct place in the control. The reason im using threading is that once i start dragging an object (button) the sampling of the x and y coordinates pauses. Thus i need to run it in another thread. My problem is that i can't seem to get _GetLocalMouseCoordinates to run in a thread of its own, i get this error C:\Documents and Settings\My Documents\Visual Studio Projects\DragNDrop\DragDrop.cs(359): Method 'DragNDrop.Form1._GetLocalMouseCoordinates(object, System.Windows.Forms.MouseEventArgs)' does not match delegate 'void System.Threading.ThreadStart()' The code is below, i have only pasted the "vital" part though. I hope that someone cna help. Thanks alot in advance! using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using System.Threading; namespace DragNDrop { /// /// Summary description for Form1. /// /// Huske/tænke liste /// /// 1. Threading hvor hurtig opdaterings tid kan formen klare uden at choke? /// public class Form1 : System.Windows.Forms.Form { private System.Windows.Forms.Panel pnlDrag; private System.Windows.Forms.Panel pnlDrop; private System.Windows.Forms.Label lblDrag; private System.Windows.Forms.Label lblDrop; private System.Windows.Forms.Button btnDrag; private System.Windows.Forms.Button btnPush; private System.Windows.Forms.StatusBar statusBarGlobal; private System.Windows.Forms.StatusBar statusBarLocalDrop; private System.Windows.Forms.StatusBar statusBarLocalDrag; // My generated variables etc. public int iXCoorDrag; public int iYCoorDrag; public int iXCoorDrop; public int iYCoorDrop; public int iXCoorGlobal; public int iYCoorGlobal; public Thread GlobalMouseThread; public Thread LocalMouseThread; public bool bStopthread; /// /// Required designer variable. /// private System.ComponentModel.Container components = null; public Form1() { // // Required for Windows Form Design

    S 1 Reply Last reply
    0
    • Y Yannielsen

      Hi im new at these forums, so this is my first post, i hope that some of you guys could help me out with this problem i have. I'm building a drag n' drop program that will allow a user to drag n drop an item (like a button) from one control to another. Currently i have a problem managing threads, or rather parsing data between them. My problem is this. I need to sample the mouse's x and y coordinates for each control so that it will drop the item at the correct place in the control. The reason im using threading is that once i start dragging an object (button) the sampling of the x and y coordinates pauses. Thus i need to run it in another thread. My problem is that i can't seem to get _GetLocalMouseCoordinates to run in a thread of its own, i get this error C:\Documents and Settings\My Documents\Visual Studio Projects\DragNDrop\DragDrop.cs(359): Method 'DragNDrop.Form1._GetLocalMouseCoordinates(object, System.Windows.Forms.MouseEventArgs)' does not match delegate 'void System.Threading.ThreadStart()' The code is below, i have only pasted the "vital" part though. I hope that someone cna help. Thanks alot in advance! using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using System.Threading; namespace DragNDrop { /// /// Summary description for Form1. /// /// Huske/tænke liste /// /// 1. Threading hvor hurtig opdaterings tid kan formen klare uden at choke? /// public class Form1 : System.Windows.Forms.Form { private System.Windows.Forms.Panel pnlDrag; private System.Windows.Forms.Panel pnlDrop; private System.Windows.Forms.Label lblDrag; private System.Windows.Forms.Label lblDrop; private System.Windows.Forms.Button btnDrag; private System.Windows.Forms.Button btnPush; private System.Windows.Forms.StatusBar statusBarGlobal; private System.Windows.Forms.StatusBar statusBarLocalDrop; private System.Windows.Forms.StatusBar statusBarLocalDrag; // My generated variables etc. public int iXCoorDrag; public int iYCoorDrag; public int iXCoorDrop; public int iYCoorDrop; public int iXCoorGlobal; public int iYCoorGlobal; public Thread GlobalMouseThread; public Thread LocalMouseThread; public bool bStopthread; /// /// Required designer variable. /// private System.ComponentModel.Container components = null; public Form1() { // // Required for Windows Form Design

      S Offline
      S Offline
      Sean Michael Murphy
      wrote on last edited by
      #2

      eclipsedk wrote: C:\Documents and Settings\My Documents\Visual Studio Projects\DragNDrop\DragDrop.cs(359): Method 'DragNDrop.Form1._GetLocalMouseCoordinates(object, System.Windows.Forms.MouseEventArgs)' does not match delegate 'void System.Threading.ThreadStart()' Ahhh, a more decriptive error there could not be. I can't judge the rightness of your overall algorithm, but the problem here is that you're trying to start a method that does not match the parameter list and return value specified by the ThreadStart delegate http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemthreadingthreadstartclasstopic.asp[^]. You can only start methods using that delegate that return void and accept no parameters. _GetGlobalMouseCoordinates matches the delegate. _getLocalMouseCoordinates on the other hand, wants an object and a MouseEventArgs. Share and enjoy. Sean

      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