Hi all, So before I went and posted ~800 lines of code, I have 2 questions: 1: What is the preferred way for us to post "complex" C++ (of course, this is just a .h, .cpp, and main cpp but it's still a lot of lines) that wont just be obnoxious to read/debug? (I guess.. what is the proper etiquette here?) 2: Maybe I don't have to post it, and I can get theory help - I have a socket server that spawns threads with mutexes to control everything as needed (I think I am doing it right). When I …

Member Avatar
Member Avatar
+0 forum 7

0 down vote favorite I have created a network scanner, that looks for a specific port on a range of IP's. I would like to thread the application but I am getting and error message ERROR: for worker in range(network.hosts): TypeError: 'method' object cannot be interpreted as an integer Now I understand why the error is there it is because the IP Address is not an INT. However, what I would prefer to do is split the subnet into equal parts and run X number of IP's on a per thread bases. Example Thread 1 192.168.1 - 30 Thread 2 …

Member Avatar
Member Avatar
+0 forum 1

I have two forms the first FrmRecipe.vb form has all my calulations and functions in it the second FrmReports has a crystal report viewer with loads of reports. I am trying to call the report as a thread so that the main from is still working however when the treads are complete my application closes I am calling Me.BeginInvoke(New MethodInvoker(AddressOf FrmReports.PrintMasterFormulationToprinter)) Can anyone point me in the right direction?

Member Avatar
Member Avatar
+0 forum 3

Hi, I got multiple threads in different classes created in this manner: private ThreadStart someName_TS; public Thread someName_Thread; public void someName() { someName_TS = new ThreadStart(someNameThread); someName_Thread = new Thread(someName_TS); someName_Thread.Start();} } private void someNameThread() { while(!Shutdown) { //Do heavy work } } The heavy work is set to a "while" statement that is always set to false unless the user wants to close the application. Now on my main form I got the following FormClosing code: if (e.CloseReason == CloseReason.UserClosing) { e.Cancel = true; guiThread.closeApp(); } Now where I think I need help is that I just made a …

Member Avatar
Member Avatar
+0 forum 3

Hey, I have been reading Java oracle tutorials. I read this thing. Suppose, for example, class MsLunch has two instance fields, c1 and c2, that are never used together. All updates of these fields must be synchronized, but there's no reason to prevent an update of c1 from being interleaved with an update of c2 — and doing so reduces concurrency by creating unnecessary blocking. Instead of using synchronized methods or otherwise using the lock associated with this, we create two objects solely to provide locks. public class MsLunch { private long c1 = 0; private long c2 = 0; …

Member Avatar
Member Avatar
+0 forum 1

I'm trying to add a progress bar to a working theaded program that uses a cancelation token too. The structure of the program is: I have a button "BeginButton" that calls the function "MyFunction()". The function runs in another thread and a cancellation token listens if I press a Cancel button. I needed to add the thread since the UI freezes when MyFunction() runs and I wasn't able to stop it. Since the MyFunction() reads a file in chunks of 1024 bytes, my logic to show the progress is get the 1% of File.Length and check when the loop increases …

Member Avatar
Member Avatar
+0 forum 2

I have a Windows Forms application (not WPF) in which from the main form (UI thread) I am creating a separate thread to perform a long period of test execution. The idea is that the user starts the testing by clicking a button on the main form; when the user wants the testing to stop, the button on the main form is clicked again. This part works alright. The main form is comprised of two tabs; a control tab containing file input boxes, radio buttons and the standard button used to start/stop the new thread. The second tab is a …

Member Avatar
Member Avatar
+0 forum 1

Run two calls to a function simultaneously with this threading @background decorator.

Member Avatar
Member Avatar
+5 forum 19

Hello all, My question is hopefully particular enough to not relate to any of the other ones that I've read. I'm wanting to use subprocess and multiprocessing to spawn a bunch of jobs serially and return the return code to me. The problem is that I don't want to wait() so I can spawn the jobs all at once, but I do want to know when it finishes so I can get the return code. I'm having this weird problem where if I poll() the process it won't run. It just hangs out in the activity monitor without running (I'm …

Member Avatar
Member Avatar
+0 forum 10

I am on OSx and I am trying to exit the program by pressing CTRL+C. but it seems like even if I have a signal handler registered in main thread it doesn't exit while the thread is executing on pressing CTRL+C. Here is a piece of cake where I am trying to download 3 mp3 files from internet each in separate thread. import Queue import urllib2 import os import signal import sys import time import threading from socket import error as _SocketError urls = ["http://broadcast.lds.org/churchmusic/MP3/1/2/nowords/271.mp3", "http://s1.fans.ge/mp3/201109/08/John_Legend_So_High_Remix(fans_ge).mp3", "http://megaboon.com/common/preview/track/786203.mp3"] queue = Queue.Queue() def do_exit(sigNum, stack): # handle unix signal recived and exit …

Member Avatar
Member Avatar
+0 forum 1

I am trying to establish a pause and play communication between threads.I am spawning two threads for two forms at the startup, one is the mainthread which is for mainwindow and second thread of form2, var thread = new Thread(ThreadStart); thread.TrySetApartmentState(ApartmentState.STA); thread.Start(); private static void ThreadStart() { Application.Run(new SecondForm()); // other form started on its own UI thread } Mainwindow has a button on clicking which multiple threads would be spawn for different operations - it executes without pause until the intended jobs are complete. In the second form I have two buttons stop, and start clicking on which I …

Member Avatar
+0 forum 0

In a past prac. exam for an algorithm course I'm doing is the challenge below, and their are no solutions but it seems like a really interesting one to solve. Can someone please help and point me in the right direction, I would like to try this on my own, but please give some assistance. I need to write a multithreaded program (using pthreads, code must run on linux, i'm using ubuntu maverick) to simulate a shuttle that operates on a circuit, stopping at the stadium, and the city center only. 1) The shuttle waits until the occupants signal for …

Member Avatar
Member Avatar
+0 forum 14

I've been asked to edit the code in this post http://www.daniweb.com/software-development/java/threads/455560/java-recursion-brute-force-sim so that it "Runs the function as a thread which wouldn’t then hang the program whilst it’s waiting for the result". I've looked it up, but I'm struggling to apply it to this program, any tips?

Member Avatar
Member Avatar
+0 forum 10

can anyone give me some good references or links or some guidelines to start with this ? i need to learn this. like i want to know how can i implement malloc, calloc, realloc etc. for this thing also, what do i need to learn firstly ? thanks. any kind of help will be appreciated.

Member Avatar
Member Avatar
+0 forum 1

Hi Folks, I am writing an app that involves Client -> Server -> Client communication (one way traffic). I have my data transmitted from client A to the server, simple to test, just print to console, however, I'm trying to test to see if the data has been sent on to the next client. I have tried a text view, nothing is displaying in this view however, now I don't know if that's because the data hasn't arrived or indeed because I've coded it wrong. I'm not very experienced in android. I've attached my code below, if anyone can help …

Member Avatar
Member Avatar
+0 forum 1

[B]!USING PYTHON 3.1![/B] Hello DaniWeb! Today I'm going to be posting a [B]simple[/B] threading tutorial. First of all, what is threading? Well, threading is just another way of doing a side task without interrupting the main program. Now here's a simple example. Let's say we are going to make a simple program. When the program starts it is going to start a timer, and it will show the time. Now, observe these 2, similar programs. Good version: [CODE] import threading import time threadBreak = False def TimeProcess(): while not threadBreak: print (time.time() - startTime) startTime = time.time() threading.Thread(target = TimeProcess).start() …

Member Avatar
Member Avatar
+3 forum 13

Hi to all, I'm using the WIA Aut. Library [url]http://www.microsoft.com/downloads/details.aspx?familyid=a332a77a-01b8-4de6-91c2-b7ea32537e29&displaylang=en[/url] , trying to capture photos from 5 digital cameras (Nikon D90) USB-connected to my pc. Now, I partially achieved my goal, what I do is: - loop through the attached devices, connecting to every camera; - fotocamera.ExecuteCommand (WIA.CommandID.wiaCommandTakePicture) ; - other image processing operations... Everything works fine but... the workflow is camera1 -> connect -> grab pic. => camera 2 -> connect -> grab pic. => camera 3..... What I'd like is to make them shoot all at the same moment (...why? well, D90 waits around 1 sec. after a …

Member Avatar
Member Avatar
+0 forum 6

What is the way that need to be implemented in java to make a server broadcasts a voice to multiple clients, instead of broadcast voice only to one client? for example I am doing a server which can broadcast voice to multiple clients at the same time, now my server can only broadcast to one clien.

Member Avatar
Member Avatar
+0 forum 2

public class Thread7 implements Runnable { public static void main(String r[]) { Thread t = new Thread(new Thread7()); t.start(); public void run() { System.out.println("C"); System.out.println("D"); } System.out.println("A"); try { t.join(); System.out.println("B"); } catch(Exception e){} } } Query1: On compiling this program I get "illegal start of expression" error pointing to public void run. But when I remove that block of code and place it outside main() the program compiles and runs successfully. What is the rule behind it? Query2: After I place run() outside main() the output is ACDB. What I don't understand is after t.start() is invoked shouldn't the …

Member Avatar
Member Avatar
+0 forum 1

Hi guys, So I'm busy writing an application that needs to update a list from the web after a certain amount of time. main.py file class Gui: def ...... def ...... def ...... def on_update_click(): update() app=Gui() Gtk.main() So when the program loads up, user will click the update button to update the list. I'd like the list to be updated every 6 hrs, so the update function should still run in the background update.py file: def update(): #update list time.sleep(6hrs) I suspect I'll have to use threading. my thinking is: Gtk.main() runs #thread 1 when the user clicks the …

Member Avatar
Member Avatar
+0 forum 2

Being on a core i5 sandybridge mobile processor, I have the option to have dual core, hyperthreading, or both enabled. Which should be disabled to lengthen the battery life and still have decent performance?

Member Avatar
Member Avatar
+0 forum 3

So awhile back I came here asking for help trying to read in data from a webpage, more specifically the HTML. I was running into an issue where the data wasn't actually being read (as if it hadn't loaded in). I had to put the program aside for awhile as life got busy, but I finally have time to come back to it. The page I am trying to read in looks like this (it's a roster and there are many of them, each for a different clan) http://worldoftanks.com/community/clans/1000000954-SAC/ Now I initally tried using code like the following WebClient myWebClient …

Member Avatar
Member Avatar
+0 forum 2

Hey all, I was hoping I could get some advice on designing the proper threading for our project. A little background info - our company does simulators of complex electrical/mechanical systems. These simulators could have fuel systems, electrical systems, pneumatic pressure systems, etc. I suppose you can just think of a car and that's close enough. We have done many of these simulators and have no problems with the systems themselves. However, we get requests from customers that have drastically different parts. Think of simulating one model of a car, including the ability to fail every individual component and system, …

Member Avatar
Member Avatar
+0 forum 2

I'm trying to do some socket programming in java. what i have is, i've written this program to create a server and client on my local machine and make separate two threads for socket input and out put in [B]Se.java[/B] file. Similarly two separate threads for socket input and output at client side in file [B]Cl.java[/B] Now, when i compile both of them they show no errors or exceptions but when i run it, the server with some exception continues but client crashes i dont know what seems to be wrong.[B]all i want to do is create two threads for …

Member Avatar
Member Avatar
+0 forum 6

I am trying to create a a splash screen... I have attached the image file..please have a look.. the splash screen performs a diagnostic procedure and displayed the results in a multi-line label.. I have used another thread to write msgs as results in label.. and its working as it is supposed to work.. if it finds out that there is an error in registry or database connectivity.. it will load "frm_maintainance".. Its almost done... The only thing I am having trouble with is when there is no error, i want to close the splash screen and open the "form1" …

Member Avatar
Member Avatar
+0 forum 3

I am designing an application which communicates with another device via a serial port. My application buffers the received binary data until the data is valid/of known format, does some processing and then writes back a response. I understand this model is known as the consumer/producer model. The issue I am having with properly implementing this model is that the message processing part of my application is fairly complex and involves calls to other classes/methods, etc., and when spawning a new thread I can only pass it one function. How can I best implement this? Thank you for any help …

Member Avatar
Member Avatar
+0 forum 2

Hey everyone. I have recently decided to try and learn how to use java Sockets for client/server communication, as well as swing and threads, etc. and have (pretty much) completed a small client server application. The application is basically a syntax-highlighting notepad, a client swing GUI which connects to a (multi-threaded) server which handles data being sent to each client. The main function of the program is turn-based code editing: [LIST=1] [*]Client 1 Connects to Server [*]Client 2 Connects to Server [*]Client 1 requests Control of the program Lock [*]Client 1 edits the source, and then clicks "send data" [*]On …

Member Avatar
Member Avatar
+0 forum 9

Hey everyone, I've been struggling with this problem for hours now and I have read and tried every example I could find but did not find a solution to my problem: I have a DLL written in C#. The DLL export function calls three functions: PrepareData(): Heavy calculations ComputeNN(): Mild calculations GUI(): Creates/updates GUI that uses above calculation values So basically the DLL looks as follows: [CODE] [DllExport("NNExportDLL", CallingConvention = CallingConvention.StdCall)] static double NNExportDLL([MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] double[] training_data, int training_data_size, int inputs, int outputs, int training_sets, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] double[] neural_input, int epochMax, int hiddenLayerNeurons, double Low_Normalize, double …

Member Avatar
Member Avatar
+0 forum 9

Hi, I have a custom httphandler (HttpUploadHandler.ashx) which is used for handling requests from a file uploader. It collects all the files from a client then fires a thread to do some processing on the files. When large amounts of files are added it will throw 'Thread was being aborted' exception. I have checked around on the internet and the going reason for this is that Response.End, Response.Redirect, or Server.Transfer was used. I have not used any of these methods, so it must be called by the system. So my question is this, how can I safely start background tasks …

Member Avatar
+0 forum 0

Hello, first this is not a homework assignment so please respond whenever you have time as a speedy solution is not exactly needed. I have been learning C# recently from a microsoft book and had an idea of a program i want to make. Basically i want to be able to read a text file, then after reading it line by line send the lines somewhere else WITH a time delay. Here is where i have stalled. I do not know how to send the text, then wait lets say 20 sec, then send the next line and so on.So …

Member Avatar
Member Avatar
+0 forum 4

The End.