C# :: Sleep / Wait - Unity 3D

Jun 3, 2013

I have been trying to make a sleep function in C# that will allow the game to be briefly paused when played. I am using Unity 3D.

View 2 Replies


ADVERTISEMENT

C# :: Wait For Thread To Finish Without Using Sleep?

Apr 30, 2012

After i've created a thread,

Code:
Thread thread = new Thread(new ThreadStart(alpha.ThreadProc)); h

How to wait for that thread to finish without using Sleep?

View 8 Replies View Related

C/C++ :: Getline Won't Wait For Input

Jun 6, 2014

Down on line 74, it does not wait cor an input, it simply says ...you failed.

#include <iostream>
#include <string>
#include <Windows.h>
#include <cstdlib>
using namespace std;
//prototyping--
void flater();

[Code] ....

View 6 Replies View Related

C++ :: Program Output That Doesn't Wait For Replies But Still Captures Them

Jul 21, 2013

I am trying to write a program that can communicate over a very latent internet connection involving a cellular modem. I have some software packages that handle all the telnet like business and will pipe stdout and stdin to a program I can have it execute.

The problem I am running into is that I have to send about 900 ASCII commands to an instrument to request data but it takes about a second between when a command goes out and when a reply comes back. This will wind up taking a very long time and I am looking to speed it up. All of the commands are independent of the reply so what I need to do is create a program that can send all 900 commands with maybe 10ms break between them and to not wait for a reply. It then needs to read the replies and write them straight to a file.

It seems like this should be achievable in C++ but I only have a very basic understanding of the language and thus am not sure where to start.

I am open to using other languages but thought C++ would be a reasonably good start so I can distribute the program to my coworkers. All of our work machines are Windows but if there is a simpler solution from Linux, I should be able to work something out. I'm just trying to avoid complication.

View 5 Replies View Related

C/C++ :: Can Client Wait To Open A File Until Server Has Made It?

Sep 30, 2014

I have a client/server program. My Client process spawns my server process using a `fork()` and `system()` call. The client and the server are meant to communicate to each other through named piped, that is a requirement of my homework. The client and the server are supposed to initially send a message to the other one, through a pipe, to confirm that a connection is made. My issue is that my client is trying to open one of the named pipes before the server has a chance to make it. This doesn't always happen though. Occasionally, it will run fine. Is there some way to synchronize this?

My overall goal is to get a filename and search target from the user, send those to the server through a named pipe. And the server searches for the target and sends info back.

OUTPUT:

Client: PID 2986 - Running on Tue Sep 30 20:59:28 2014
Client: PID 2986 - Enter File Name: largeSampleText.txt
Server PID 2988 - Running on Tue Sep 30 20:59:32 2014
Server: PID 2988 - Synchronized to Client.//This means the client-to-server fifo is working
There was an error opening serverToClientfifo//This means client couldn't open the server-to-client fifo
error is: 2//This means the fifo doesn't exist yet

[Code] ....

CORRECT OUTPUT:

Client: PID 2542 - Running on Tue Sep 30 20:58:44 2014
Client: PID 2542 - Enter File Name: largeSampleText.txt
Server PID 2557 - Running on Tue Sep 30 20:58:54 2014
Server: PID 2557 - Synchronized to Client.

[Code] ....

RELEVANT CLIENT CODE:

int main() {
char requestedFileName[1024];
//Get initial information on the client
pid_t clientPID = getpid();
time_t currentTime = time(0);
char* stringTime= ctime(¤tTime);

[Code] ....

I tried creating both of my fifos in my client and my output changed to this

Client: PID 3150 - Running on Tue Sep 30 21:23:17 2014
Client: PID 3150 - Enter File Name: largeSampleText.txt
Client: PID 3150 - Enter Target:
Server PID 3153 - Running on Tue Sep 30 21:23:21 2014
was
Client: PID 3150 - Input File >>>largeSampleText.txt<<<
Client: PID 3150 - Target >>>was<<<
Client: PID 3150 - Synchronized to Server
Server received unexpected connection message
Message: was
Terminating

So It appears like the client went ahead and put `requestedFileName` and`requestedTarget`into the pipe and the server read out `requestedTarget` instead of the connection message. Not sure why though

View 1 Replies View Related

Visual C++ :: Create Process And Wait For Input Idle

Feb 13, 2014

I have a problem with creating a process and waiting until the main window of the new process was shown. I thought I can wait for it with

WaitForInputIdle(pi.hp,INFINITE);

But when the function returns, the handle of the main window of the new process is not available. If I include also a ::Sleep(), the new window is available. Sleep is a bad solution. How can I do it?

View 3 Replies View Related

C# :: How To Get Monitor Out Of Sleep Mode

Jul 12, 2012

How can you get a monitor out of sleep mode in c#?

I tried the following, but then the monitor wakes up and falls back to sleep mode immediately.

Code:

uint SC_MONITORPOWER = 0xF170;
uint WM_SYSCOMMAND = 0x0112;
SendMessage(this.Handle, WM_SYSCOMMAND,
(IntPtr)SC_MONITORPOWER, (IntPtr)(-1));

View 1 Replies View Related

C :: Sounding A Beep While Using Sleep

Feb 22, 2015

I need to be able to sound an alarm (a beep) for 10 seconds in C.this beep has to mirror a sleep period, before the code loops back to the beginning. Now I've got the loop sorted and I can make it beep and sleep, however the beep follows 10 seconds after the sleep..Both the beep and the sleep need to happen at the same time..

View 3 Replies View Related

C++ :: Copy And Paste Function From Other Source Program Doesn't Wait For Input

Nov 27, 2013

I'm working on a project that requires to make modifications to certain functions. So, I'll copy and paste the function to a new source code so I'm just working on the function with the entire program running. When I run the function by itself, it works fine. But when I copy and paste the function back to it's spot, the program doesn't wait for input at the cin.getline & it did wait when I ran just the function by itself. I'm using Dev C++ if that makes a difference.

View 2 Replies View Related

Visual C++ :: What Header For Sleep Function

Jan 26, 2014

I have been googling for a long time to find the header used with sleep().

View 5 Replies View Related

C++ :: Sleep Function When Drawing Analog Clock

Jan 19, 2015

Make an "analog clock" that is, a clock with hands that move. You get the time of day from the operating system through a library call. A major part of this exercise is to find the functions that give you the time of day and a way of waiting for a short period of time (e.g., a second for a clock tick) and to learn to use them based on the documentation you found. Hint: clock(), sleep().

OK, I wrote below code. It is in its primary stages and has not been completed yet.

#include <GUI.h>
#include <time.h>
#include <iostream>
using namespace Graph_lib;

[Code] .....

I expect the system in void clock_hands() (line 38) attaches hour1 (line 41) then waits for 1000 ms (using Sleep(1000)) then detaches hour1 and attaches hour2 this time. But it doesn't occur in practice. When the system reaches Sleep(1000); it seems to go into a comma! It doesn't show the hour1 so seeing the movement of clock ticks by the clock's hands will not be possible.

View 5 Replies View Related

C++ :: Using Clear Device And Sleep Functions In Graphics

Dec 14, 2014

I have a college project which is a car racing game using C++ and the old-school graphics library BGI. After I draw the map and placed the objects(Car,obstacles,road's borders etc..)I added Sleep(); function to the function named Obstacles(); but the problem is, I can't move the car with the right&left arrows.a

Another problem,If I added a cleardevice(); command all objects disappears only the obstacles function keeps working. the Code is here:

char c;
do{
c = (char)getch();
if (c == KEY_LEFT) {
x = x - 10, x1 = x1 - 10;
} if (c == KEY_RIGHT) {
x = x + 10, x1 = x1 + 10;

[code].....

note: this is not the whole code, it's only a small portion of it, not a debugging question only need a hint how to fix it.

View 3 Replies View Related

Visual C++ :: Notification Supposed To Be Sent Out During Forced Sleep In XP?

Oct 2, 2012

I run the following API to put Windows XP SP3 into sleep (or standby mode) from a worker thread:

Code:
BOOL bForced = TRUE;
SetSuspendState(FALSE, bForced, FALSE);

Then in the main thread, while processing window messages:

Code:
LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam) {
if(message == WM_POWERBROADCAST) {
if(wParam == PBT_APMSUSPEND) {
AddLogMsg(_T("SUSPEND event received"));

[Code] ....

So when SetSuspendState is called with request for a 'forced' sleep mode, the PBT_APMSUSPEND notification is never broadcast. Only if I set forced parameter to FALSE I receive it.

PBT_APMRESUMEAUTOMATIC is received in either case.

PBT_APMSUSPEND is always received when run on Windows Vista/7.

View 1 Replies View Related

Visual C++ :: How To Call Sleep Function Prototype

Dec 23, 2012

I have two problems with the code below:

1. I cannot find a header file to #include that has the sleep function prototype.

2. When I add my own sleep function prototype, I get an unresolved external reference error (for _sleep, not sleep).

What must I #include to get the sleep function prototype? What lib must I include in the linker configuration to resolve the external reference? (I suspect that if I #include the correct header file, the second question might become moot.)

The "man page" at [URL] .... says the header file is <WinBase.h>. But #include'g only <WinBase.h> results in compilation errors.

A response marked "answer" at [URL] ..... says <windows.h> [sic]. #Include'g only <Windows.h> does eliminate the compilation errors.

But apparently that does not bring in the sleep function prototype. Neither does also subsequently #include'g <WinBase.h>. (Which seems to be #include'd by <Windows.h> anyway.)

But even with my own function prototype shown below, I get an unresolved external reference for _sleep. Is that a symptom of my problem: my sleep reference is changed to _sleep? If so, how can avoid that?

According to "man page" (see link above), the external should be resolve in kernel32.lib. And kernel32.lib does appear in the "Additional Dependencies" list under Configuration Properties Linker Input.

Since I am not using C++ features, I tried setting "Compile as C" under Configuration Properties C/C++ Advanced, to no avail.

My code....

#include "stdafx.h"
#include <stdlib.h>
#include <time.h>
#include <Windows.h>
void sleep(DWORD msec); // added later
int _tmain(int argc, char* argv[])

[Code] ....

View 3 Replies View Related

Visual C++ :: Drawing Analog Clock - Sleep Function

Jan 19, 2015

The question says: Make an "analog clock" that is, a clock with hands that move. You get the time of day from the operating system through a library call. A major part of this exercise is to find the functions that give you the time of day and a way of waiting for a short period of time (e.g., a second for a clock tick) and to learn to use them based on the documentation you found. Hint: clock(), sleep().

OK, I wrote below code. It is in its primary stages and has not been completed yet.

Code:
#include <GUI.h>
#include <time.h>
#include <iostream>
using namespace Graph_lib;
//---------------------------------
class Dynamic_clock : public Window {

[Code] .....

I expect the system in void clock_hands() (line 38) attaches hour1 (line 41) then waits for 1000 ms (using Sleep(1000)) then detaches hour1 and attaches hour2 this time. But it doesn't occur in practice. When the system reaches Sleep(1000); it seems to go into a comma! It doesn't show the hour1 so seeing the movement of clock ticks by the clock's hands will not be possible.

[URL] ....

View 14 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved