Search Results

Search found 1455 results on 59 pages for 'threading'.

Page 17/59 | < Previous Page | 13 14 15 16 17 18 19 20 21 22 23 24  | Next Page >

  • How to show progressbar in win32 application?please help me!

    - by kiddo
    Hi all,I am trying to display a progress bar with some informations in it,say for example am reading files ..I want to display the progress bar progressing with the filename that is being read etc..I am doing this in an win 32 application.I know that we should do it using thread but am not quite familiar with that,check the below picture example,thats what i need it exactly.

    Read the article

  • C++ setTimout function ?

    - by Quandary
    What's the cheapest way for a JavaScript like setTimeout-function in C++? I would need this: 5000 miliseconds from now, start function xy (no parameters, no return value). The reason for this is I need to initialize COM for text to speech, but when I do it on dll attach, it crashes. It works fine however if I do not call CoInitialize from dllmain. I just need to call CoInitialize and CoCreateInstance, and then use the instance in other functions. I can catch the uninitialized instance by checking for NULL, but I need to initialize COM - without crashing.

    Read the article

  • C#: Populating a UI using separate threads.

    - by Andrew
    I'm trying to make some sense out of an application Ive been handed in order to track down the source of an error. Theres a bit of code (simplified here) which creates four threads which in turn populate list views on the main form. Each method gets data from the database and retrieves graphics from a resource dll in order to directly populate an imagelist and listview. From what Ive read on here (link) updating UI elements from any thread other than the UI thread should not be done, and yet this appears to work? Thread t0 = new Thread(new ThreadStart(PopulateListView1)); t0.IsBackground = true; t0.Start(); Thread t1 = new Thread(new ThreadStart(PopulateListView2)); t1.Start(); Thread t2 = new Thread(new ThreadStart(PopulateListView3)); t2.Start(); Thread t3 = new Thread(new ThreadStart(PopulateListView4)); t3.Start(); The error itself is a System.InvalidOperationException "Image cannot be added to the ImageList." which has me wondering if the above code is linked in some way. Iis this method of populating the UI recommended and if not what are the possible complications resulting from it?

    Read the article

  • C# BackgroundWorker RunWorkerCompleted Event

    - by Jim Fell
    My C# application has several background workers. Sometimes one background worker will fire off another. When the first background worker completes and the RunWorkerCompleted event is fired, on which thread will that event fire, the UI or the first background worker from which RunWorkerAsync was called? I am using Microsoft Visual C# 2008 Express Edition. Any thoughts or suggestions you may have would be appreciated. Thanks.

    Read the article

  • TerminateProcess and deadlocks

    - by Tony
    Is it real that the TerminateProcess function in Windows could hang because the threads inside the process were stuck in a deadlock? Example: Process A is running under Process B's control, now Process A gets into a deadlock and Process B detects this and decides to 'Kill' process A using TerminateProcess. Would it be successful in killing the hung Process A?

    Read the article

  • UI Thread .Invoke() causing handle leak?

    - by JYelton
    In what circumstances would updating a UI control from a non-UI thread could cause the processes' handles to continually increase, when using a delegate and .InvokeRequired? For example: public delegate void DelegateUIUpdate(); private void UIUpdate() { if (someControl.InvokeRequired) { someControl.Invoke(new DelegateUIUpdate(UIUpdate)); return; } // do something with someControl } When this is called in a loop or on timer intervals, the handles for the program consistently increase.

    Read the article

  • Wait between tasks with SingleThreadExecutor

    - by Lord.Quackstar
    I am trying to (simply) make a blocking thread queue, where when a task is submitted the method waits until its finished executing. The hard part though is the wait. Here's my 12:30 AM code that I think is overkill: public void sendMsg(final BotMessage msg) { try { Future task; synchronized(msgQueue) { task = msgQueue.submit(new Runnable() { public void run() { sendRawLine("PRIVMSG " + msg.channel + " :" + msg.message); } }); //Add a seperate wait so next runnable doesn't get executed yet but //above one unblocks msgQueue.submit(new Runnable() { public void run() { try { Thread.sleep(Controller.msgWait); } catch (InterruptedException e) { log.error("Wait to send message interupted", e); } } }); } //Block until done task.get(); } catch (ExecutionException e) { log.error("Couldn't schedule send message to be executed", e); } catch (InterruptedException e) { log.error("Wait to send message interupted", e); } } As you can see, there's alot of extra code there just to make it wait 1.7 seconds between tasks. Is there an easier and cleaner solution out there or is this it?

    Read the article

  • Push notification or thread with timer

    - by neha
    Hi all, In my application, I'm having functionality like twitter that when you have not refreshed your screen, and if there're new messages then you get this message that "You have n new messages" and a refresh button, which on press will refresh the screen. I'm basically fetching all the data from an xml with some url. In case of thread, I need to call a timer after some time period which might affect the app performance. Can anybody please suggest wheather what will be better to use push notifications or thread with timer? Thanx in advance.

    Read the article

  • Does Monitor.Wait ensure that fields are re-read?

    - by Marc Gravell
    It is generally accepted (I believe!) that a lock will force any values from fields to be reloaded (essentially acting as a memory-barrier or fence - my terminology in this area gets a bit loose, I'm afraid), with the consequence that fields that are only ever accessed inside a lock do not themselves need to be volatile. (If I'm wrong already, just say!) A good comment was raised here, questioning whether the same is true if code does a Wait() - i.e. once it has been Pulse()d, will it reload fields from memory, or could they be in a register (etc). Or more simply: does the field need to be volatile to ensure that the current value is obtained when resuming after a Wait()? Looking at reflector, Wait calls down into ObjWait, which is managed internalcall (the same as Enter). The scenario in question was: bool closing; public bool TryDequeue(out T value) { lock (queue) { // arbitrary lock-object (a private readonly ref-type) while (queue.Count == 0) { if (closing) { // <==== (2) access field here value = default(T); return false; } Monitor.Wait(queue); // <==== (1) waits here } ...blah do something with the head of the queue } } Obviously I could just make it volatile, or I could move this out so that I exit and re-enter the Monitor every time it gets pulsed, but I'm intrigued to know if either is necessary.

    Read the article

  • Is my way of doing threads in Android correct?

    - by Charlie
    Hi, I'm writing a live wallpaper, and I'm forking off two separate threads in my main wallpaper service. One updates, and the other draws. I was under the impression that once you call thread.start(), it took care of everything for you, but after some trial and error, it seems that if I want my update and draw threads to keep running, I have to manually keep calling their run() methods? In other words, instead of calling start() on both threads and forgetting, I have to manually set up a delayed handler event that calls thread.run() on both the update and draw threads every 16 milliseconds. Is this the correct way of having a long running thread? Also, to kill threads, I'm just setting them to be daemons, then nulling them out. Is this method ok? Most examples I see use some sort of join() / interrupt() in a while loop...I don't understand that one...

    Read the article

  • Run sub on main thread from separate thread [VB.NET|SerialPort]

    - by Steven
    I'm reading data from a serial port, but the DataReceived event of SerialPort is handled on it's own thread. I want to handle this on the main thread, but simply declaring an event and raising it still results in it being processed on the SerialPort thread. I'm assuming I need to declare a delegate I can call, but I don't see how that would work. For example, I want to call Sub HandleDataReceived() on the main thread from the DataReceived thread, having HandleDataReceived() run on the main thread. How would I do this?

    Read the article

  • Thread pool stack security issue

    - by elmatador
    In a naive implementation of a thread pool, can a piece of code that is being executed read the data left by some previous code on the stack (if it was running on the same thread instance)? Also, are there any other inherent security issues connected to thread pools?

    Read the article

  • Python Terminated Thread Cannot Restart

    - by Mel Kaye
    Hello, I have a thread that gets executed when some action occurs. Given the logic of the program, the thread cannot possibly be started while another instance of it is still running. Yet when I call it a second time, I get a "RuntimeError: thread already started" error. I added a check to see if it is actually alive using the Thread.is_alive() function, and it is actually dead. What am I doing wrong? I can provide more details as are needed.

    Read the article

  • How to handle feedback from background threads if the user uses the back button?

    - by Janusz
    I have the following problem: I have an Activity where a user can start a web search showing a new activity to show a progress bar until the results are shown. Now the user can either wait for the results or maybe think about the search parameters, hit the back button and triggering a new search. The search is running in an Async Task and therefor still running if the user hits back. At the moment the thread finishes it calls some methods on the old activity causing the activity to show a dialog. This causes the system to crash because the dialog tries to show itself with a reference to an activity that is not longer present on the screen. How can I achieve a dialog that is only shown if the activity is still active?

    Read the article

  • C# Asynchronous Sockets questions.

    - by ccppjava
    Based on my reading and testing, with asynchronous sockets, the socket itself can be passed using state object (IAsyncResult result), also if store the socket as a private field, it would be captured by the callback methods. I am wondering how the IAysnResult is kepted between the BeginXXX and ReceiveXXX? It looks to me that after the BeginXXX call and the method ends, the state object would be disposed by GC if there is no reference to it. In the case of private field, how the private field is shared between threads? (As far as I know, a callback is executed using a thread from the default thread pool, which would be considered as a new thread.) Many thanks, hope the questions themselves are clear.

    Read the article

  • Painting on GtkScrolledWindow or GtkEventBox

    - by ptomato
    Using GTK, I'm trying to overlay a "More" prompt (but it could just as well be any drawing object) in the corner of a GtkTextView contained within a GtkScrolledWindow. I draw the prompt in the handler for the expose signal of the text view. It works, but when I scroll the window I get artifacts: the prompt is moved along with the contents of the text view and not erased. In order to get rid of the artifacts I trigger a redraw after each scroll. This mostly works, but you can still see the prompt jumping up and down when you scroll quickly. Is there any way to prevent this? It would be nice if the prompt just "floated" on top of the text view. I tried enclosing the scrolled window in a GtkEventBox and painting the prompt on top of that, but that didn't work either; the scrollbars and text view always paint over the prompt, even when you set the event box's window to go in front of its children's windows. UPDATE If I connect the GtkEventBox's expose callback with g_signal_connect_after(), then it is called after the expose callbacks of the GtkScrolledWindow and GtkTextView. The text view still draws over the event box though. I think this is because the scrolling happens asynchronously. Anybody got any idea how I can prevent my drawing from being overwritten?

    Read the article

  • In C# ,how do I terminate a thread that has had its call stack corrupted?

    - by Emil D
    I have a thread in my application that is running code that can potentially cause call stack corruption ( my application is a testing tool for dlls ). Assuming that I have a method of detecting if the child thread is misbehaving, how would I terminate it? From what I read, calling Thread.Abort() on the misbehaving thread would be equivalent to raising an exception inside it.I fear that that not be a good idea, provided the call stack of the thread might be corrupted.Any suggestions?

    Read the article

  • Multithreading: Read from / write to a pipe

    - by Tero Jokinen
    I write some data to a pipe - possibly lots of data and at random intervals. How to read the data from the pipe? Is this ok: in the main thread (current process) create two more threads (2, 3) the second thread writes sometimes to the pipe (and flush-es the pipe?) the 3rd thread has infinite loop which reads the pipe (and then sleeps for some time) Is this so far correct? Now, there are a few thing I don't understand: do I have to lock (mutex?) the pipe on write? IIRC, when writing to pipe and its buffer gets full, the write end will block until I read the already written data, right? How to check for read data in the pipe, not too often, not too rarely? So that the second thread wont block? Is there something like select for pipes? It is possible to set the pipe to unbuffered more or I have to flush it regularly - which one is better? Should I create one more thread, just for flushing the pipe after write? Because flush blocks as well, when the buffer is full, right? I just don't want the 1st and 2nd thread to block.... [Edit] Sorry, I thought the question is platform agnostic but just in case: I'm looking at this from Win32 perspective, possibly MinGW C...

    Read the article

  • Problem using GDI+ with multiple threads (VB.NET)

    - by Joe B
    I think it would be best if I just copy and pasted the code (it's very trivial). Private Sub Main() Handles MyBase.Shown timer.Interval = 10 timer.Enabled = True End Sub Private Sub Form1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint e.Graphics.DrawImage(image, 0, 0) End Sub Private Sub tick() Handles timer.Elapsed Using g = Graphics.FromImage(image) g.Clear(Color.Transparent) g.DrawLine(Pens.Red, 0 + i, 0 + i, Me.Width - i, Me.Height - i) End Using Me.Invalidate() End Sub An exception, "The object is currently in use elsewhere", is raised during the tick event. Could someone tell me why this happens and how to solve it? Thanks.

    Read the article

  • boost::this_thread::disable_interruption usage confusion

    - by Evgenii
    boost/thread/pthread/shared_mutex.hpp contains this code: ... #include <boost/thread/detail/thread_interruption.hpp> ... class shared_mutex { ... void lock_shared() { boost::this_thread::disable_interruption do_not_disturb; boost::mutex::scoped_lock lk(state_change); while(state.exclusive || state.exclusive_waiting_blocked) { shared_cond.wait(lk); } ++state.shared_count; } ... }; but boost/thread/detail/thread_interruption.hpp does not contain implementation of disable_interruption, only the prototype. in boost_1_42_0/libs/thread/src/pthread we don't have the implementation too how does it work!???

    Read the article

  • emit signal from thread

    - by Umesha MS
    Hi, I am writing a sample which uses thread to do some background processing. In the thread I am trying to emitting a signal. But it is not coming to slot. While connecting I checked the value of “connect()” function value , it is returning value as true. One thing to notice is in the run method I am not using “exec() “ . Please help me to solve this problem.

    Read the article

< Previous Page | 13 14 15 16 17 18 19 20 21 22 23 24  | Next Page >