Hi I am working on the sleeping barber problem. with the addition of having priority customer when they arrive they go in the front of the line and they are the next ones to get a haircut.
I'm using a linkedlist and if I see a priority customer I put him in the beginning of the list, if the customer is not priority he goes to the end o...
I need a reliable way to detect how many CPU cores are on a computer. I am creating a numerically intense simulation C# application and want to create the maximum number of running threads as cores. I have tried many of the methods suggested around the internet like Environment.ProcessorCount, using WMI, this code: http://blogs.adamsof...
The tags might not be accurate since I am not sure where the problem is.
I have a module where I am trying to read some data from a socket, and write the results into a file (append) It looks something like this, (only relevant parts included)
if __name__ == "__main__":
<some init code>
for line in file:
t = Thread(targ...
My Delphi program relies heavily on Outlook automation. Outlook versions prior to 2007-SP2 tend to get stuck in memory due to badly written addins and badly written Outlook code.
If Outlook is stuck, calling CreateOleObject('Outlook.Application') or GetActiveObject ... doesn't return and keeps my application hanging till Outlook.exe is ...
Hi,
I just found out that lazy loading in Entity Framework only works from the thread that created the ObjectContext. To illustrate the problem, I did a simple test, with a simple model containing just 2 entities : Person and Address. Here's the code :
private static void TestSingleThread()
{
using (var context = new Te...
I have a threadMethod which shows in console robotMotorsStatus every 0.5 sec. But when I try to change robotMotorsStatus in changeRobotStatus method I receive an exception. Where I need to put locks in that program.
#import "AppController.h"
@implementation AppController
extern char *robotMotorsStatus;
- (IBAction)runThread:(id)sender...
I want to get the "free memory" of a bunch of servers like this:
def get_mem(servername):
res = os.popen('ssh %s "grep MemFree /proc/meminfo | sed \'s/[^0-9]//g\'"' % servername)
return res.read().strip()
since this can be threaded I want to do something like that:
import threading
thread1 = threading.Thread(target=ge...
I've been investigating different scheduling algorithms for a thread pool I am implementing. Due to the nature of the problem I am solving I can assume that the tasks being run in parallel are independent and do not spawn any new tasks. The tasks can be of varying sizes.
I went immediately for the most popular scheduling algorithm "wo...
Hi,
I am trying to pass 2 variables from a thread, in the MainForm, to another form, but when doing so an error occurs.
private void TrackingThread( )
{
float targetX = 0;
float targetY = 0;
while ( true )
{
camera1Acquired.WaitOne( );
camera2Acquired.WaitOne( );
...
Hello everyone,
I have the following code in my program:
Thread getUsersist, getChatUsers;
getUsersList = new Thread(this, "getOnlineUsers");
getUsersList.start();
getChatUsers = new Thread(this, "getChatUsers");
getChatUsers.start();
In run(), I wish to know which thread is using run(). If its "getOnlineUsers" i will do something, ...
I have the following code running on my Android device. It works great and displays my list items wonderfully. It's also clever in the fact it only downloads the data when it's needed by the ArrayAdapter. However, whilst the download of the thumbnail is occurring, the entire list stalls and you cannot scroll until it's finished downloadi...
I'm trying to get the notification NSTaskDidTerminateNotification in my multithreaded app but I can't get it working. It does seem to work when I tested it on a single threaded app. In init I have [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(taskDidEnd:) name: NSTaskDidTerminateNotification object: myTask];...
I would like to create/use a system-wide independent universal 'counter object' that can be called via COM in a thread-safe manner.
The counter object will be passed an ID to identify which counter to return, handle the counting, 'persist' the count (occasionally), have reasonable performance (as fast as possible) perhaps capable of 10...
Hi Guys,
recently I started a project which can export some precalculated Grafix/Audio to files, for after processing.
All I was doing is to put a new Window (with progressindicator and an Abort Button) in my main xib and opened it using the following code:
[NSApp beginSheet: REC_Sheet modalForWindow: MOTHER_WINDOW modalDelegate: self...
I have a question regarding using Semaphores
HANDLE WINAPI CreateSemaphore(...);
Is there anyway I can get the current value of the semaphore?
...
Hi, I'm seeing this code in a project and I wonder if it is safe to do:
(ASP.NET MVC 2.0)
class MyController
{
void ActionResult SomeAction()
{
System.Threading.Thread newThread = new System.Threading.Thread(AsyncFunc);
newThread.Start();
}
void AsyncFunc()
{
string someString = HttpContext.Request.UrlReferrer.Au...
I'm parsing a very simple XML schema with a SAX parser in Android.
An example file would be
<Lists>
<List name="foo">
<Note title="note 1" .../>
<Note title="note 2" .../>
</List>
<List name="bar">
<Note title="note 3" .../>
</List>
</Lists>
The ... represents more note data as attributes that aren't important to question.
I use a S...
I have a method that contains the following (Java) code:
doSomeThings();
doSomeOtherThings();
doSomeThings() creates some threads, each of which will run for only a finite amount of time. The problem is that I don't want doSomeOtherThings() to be called until all the threads launched by doSomeThings() are finished. (Also doSomeThings...
Hello All,
I may be waaaay off, or else really close. Either way, I'm currently SOL. :)
I want to be able to use an extension method to set properties on a class, but that class may (or may not) be updated on a non-UI thread, and derives from a class the enforces updates to be on the UI thread (which implements INotifyPropertyChange...
If I have an object that I would like to force to be accessed from within a lock, like so:
var obj = new MyObject();
lock (obj)
{
obj.Date = DateTime.Now;
obj.Name = "My Name";
}
Is it possible, from within the AddOne and RemoveOne functions to detect whether the current execution context is within a lock?
Something like:
M...