Search Results

Search found 10883 results on 436 pages for 'thread timeout'.

Page 61/436 | < Previous Page | 57 58 59 60 61 62 63 64 65 66 67 68  | Next Page >

  • SslStream.ReadByte() blocks thread?

    - by alex
    I'm trying to write an Imap4 client. For that I use a SslStream to Connect to the Server. Everything's fine until I send the "Login" command. When I try to get an Answer to it, SslStream.ReadByte() block the thread. The result is that my programm crashes always. Whats happening here?? Code: if (ssl) { s = stream; } int cc = 0; MessageBox.Show("entered"); while (true) { int xs = s.ReadByte(); MessageBox.Show(xs.ToString()); if (xs > 0) { buf.Add((byte)xs); cc++; if (xs == '\n') { break; } if (cc > 10) MessageBox.Show(en.GetString(buf.ToArray())); } else { break; } } MessageBox.Show("left");

    Read the article

  • Are static delegates thread-safe?

    - by leypascua
    Consider this code snippet: public static class ApplicationContext { private static Func<TService> Uninitialized<TService>() { throw new InvalidOperationException(); } public static Func<IAuthenticationProvider> AuthenticationProvider = Uninitialized<IAuthenticationProvider>(); public static Func<IUnitOfWorkFactory> UnitOfWorkFactory = Uninitialized<IUnitOfWorkFactory>(); } //can also be in global.asax if used in a web app. public static void Main(string[] args) { ApplicationContext.AuthenticationProvider = () => new LdapAuthenticationProvider(); ApplicationContext.UnitOfWorkFactory = () => new EFUnitOfWorkFactory(); } //somewhere in the code.. say an ASP.NET MVC controller ApplicationContext.AuthenticationProvider().SignIn(username, true); Are delegates in the static class ApplicationContext thread-safe in the sense that multiple-threads can invoke them? What potential problems will I face if I pursue this approach?

    Read the article

  • ThreadStateException when using QueueUserWorkItem in a Timer

    - by Tim
    Hi all, I have a ThreadStateException in my winforms application. Step to reproduce : Create simple winforms app Add a button In click event, do : timer1.Interval = 1000; timer1.Tick += timer1_Tick; timer1.Start(); void timer1_Tick(object sender, EventArgs e) { ThreadPool.QueueUserWorkItem(delegate { StringCollection paths = new StringCollection { @"c:\my.txt", @"c:\my.png" }; Clipboard.SetFileDropList(paths); }); } The exception tells me : Current thread must be set to single thread apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttribute marked on it. But the main has already the [STAThread] attribute. How to solve it ? Thanks in advance for any help

    Read the article

  • C++ Static Initializer - Is it thread safe

    - by Yan Cheng CHEOK
    Usually, when I try to initialize a static variable class Test2 { public: static vector<string> stringList; private: static bool __init; static bool init() { stringList.push_back("string1"); stringList.push_back("string2"); stringList.push_back("string3"); return true; } }; // Implement vector<string> Test2::stringList; bool Test2::__init = Test2::init(); Is the following code thread safe, during static variable initialization? Is there any better way to static initialize stringlist, instead of using a seperate static function (init)?

    Read the article

  • Java - Thread safety of ArrayList constructors

    - by andy boot
    I am looking at this piece of code. This constructor delegates to the native method "System.arraycopy" Is it Thread safe? And by that I mean can it ever throw a ConcurrentModificationException? public Collection<Object> getConnections(Collection<Object> someCollection) { return new ArrayList<Object>(someCollection); } Does it make any difference if the collection being copied is ThreadSafe eg a CopyOnWriteArrayList? public Collection<Object> getConnections(CopyOnWriteArrayList<Object> someCollection) { return new ArrayList<Object>(someCollection); }

    Read the article

  • How can I pass a Context object to a thread on call

    - by Pentium10
    I have this code fragment: public static class ExportDatabaseFileTask extends AsyncTask<String, Void, Boolean> { private final ProgressDialog dialog = new ProgressDialog(ctx); protected void onPreExecute(); protected Boolean doInBackground(final String... args); protected void onPostExecute(final Boolean success); } I execute this thread as new ExportDatabaseFileTask().execute(); As you see I use a ctx as Context variable in the new ProgressDialog call, how do I pass a context to the call method? to this one: new ExportDatabaseFileTask().execute();*

    Read the article

  • Thread processing in EMS connection

    - by aladine
    I am setting up a client and exchange project and both are connecting to a remote server. Exchange will connect to the server by EMS connection. While client will connect by FIX. For the aim of building of black box testing, both client and exchange engine will be given some predefined testcases to send and receive to the server. I design the client engine with multithread processing to manipulate many testcases. Actually it is able to run succesfully. For exchange engine, I wonder that multi thread is applicable in the context that the exchange engine just need to publish a message when it received msg from subscribed topic on server. Flow of messages transmission: Client--SERVER--Exchange FIX EMS Exchange--SERVER--Client EMS FIX Thanks if you can help me on this issue.

    Read the article

  • How can CopyOnWriteArrayList be thread-safe?

    - by Shooshpanchick
    I've taken a look into OpenJDK's sources of CopyOnWriteArrayList and it seems that all write operations are protected by the same lock and read operations are not protected at all. As I understand, under JMM all accesses to a variable (both read and write) should be protected by lock or reordering effects may occur. For example, set(int, E) method contains these lines (under lock): /* 1 */ int len = elements.length; /* 2 */ Object[] newElements = Arrays.copyOf(elements, len); /* 3 */ newElements[index] = element; /* 4 */ setArray(newElements); The get(int) method, on the other hand, only does return get(getArray(), index);. In my understanding of JMM, this means that get may observe the array in an inconsistent state if statements 1-4 are reordered like 1-2(new)-4-2(copyOf)-3. Do I understand JMM incorrectly or is there any other explanations on why CopyOnWriteArrayList is thread-safe?

    Read the article

  • Grid computing projects similar to NGrid (thread based)

    - by DivdeAndConquer
    Hello there, first time poster. This is a great place for reading about programming problems. I've been looking at some grid computing projects for .Net/Mono and stumbled upon NGrid. NGrid seems really appealing for grid computing because you simply pass threads to it and there is very little modification you have to make to your code. However, I see that NGrid (http://ngrid.sourceforge.net/?page=overview) is still at version 0.7 and hasn't been updated since May 2008. So, I'm wondering if there are any other grid computing projects that use a similar thread-passing architecture and if anyone has had success using NGrid.

    Read the article

  • Does this simple cache class need thread synchronization?

    - by DayOne
    Does this simple cache class need thread synchronization ... if I remove the lock _syncLock statement will encounter any problems? I think i can remove the locks as the references should be updated correctly right? ... BUt i'm think whar happens if client code is iterating over the GetMyDataStructure method and it get replaced? Thanks! public sealed class Cache { private readonly object _syncLock = new object(); private IDictionary<int, MyDataStructure> _cache; public Cache() { Refresh(); } public void Refresh() { lock (_syncLock) { _cache = DAL.GetMyDataStructure(); } } public IDictionary<int, MyDataStructure> **GetMyDataStructure**() { lock (_syncLock) { return _cache; } } }

    Read the article

  • too many threads due to synch communication

    - by MasoudIzzy
    I'm using threads and xmlrpclib in python at the same time. Periodically, I create a bunch of thread to complete a service on a remote server via xmlrpclib. The problem is that, there are times that the remote server doesn't answer. This causes the thread to wait forever for a response which it never gets. Over time, number of threads in this state increases and will reach the maximum number of allowed threads on the system (I'm using fedora). I tried to use socket.setdefaulttimeout(10); but the exception that is created by that will cause the server to defunct. I used it at server side but it seems that it doesn't work :/ Any idea how can I handle this issue?

    Read the article

  • Serialized task distribution: use thread or epoll?

    - by hpsmouse
    Now I'm in such a situation that there is a group of predefined tasks for multiple clients to do(any client can take any task). When a client connects to the server, server choose a task from the uncompleted tasks and send it to the client. It takes a while for the client to finish the task and send the result back to the server. Since a task should be sent to only one client, server should process requests in a serialized way. Now I have two plans to do it: create a thread for each client connection and all the threads take turns accessing the task pool, or use epoll listening on all the connection and process for each event of clients. Which one is better for the job? Or is there any other ideas? The server will be run on a multi-core machine.

    Read the article

  • Do I need to syncronize thread access to an int

    - by Martin Harris
    I've just written a method that is called by multiple threads simultaneously and I need to keep track of when all the threads have completed, the code uses this pattern: private void RunReport() { _reportsRunning++; try { //code to run the report } finally { _reportsRunning--; } } This is the only place within the code that _reportsRunning's value is changed, and the method takes about a second to run. Occasionally when I have more than six or so threads running reports together the final result for _reportsRunning can get down to -1, if I wrap the calls to _runningReports++ and _runningReports-- in a lock then the behaviour appears to be correct and consistant. So, to the question: When I was learning multithreading in C++ I was taught that you didn't need to synchronize calls to increment and decrement operations because they were always one assembly instruction and therefore it was impossible for the thread to be switched out mid-call. Was I taught correctly, and if so how come that doesn't hold true for C#?

    Read the article

  • New thread per client connection in socket server?

    - by Olaseni
    I am trying to optimize multiple connections per time to a TCP socket server. Is it considered good practice, or even rational to initiate a new thread in the listening server every time I receive a connection request? At what time should I begin to worry about a server based on this infrastructure? What is the maximum no of background threads I can work, until it doesn't make any sense anymore? Platform is C#, framework is Mono, target OS is CentOS, RAM is 2.4G, server is on the clouds, and I'm expecting about 200 connection requests per second.

    Read the article

  • Simple C++ container class that is thread-safe for writing

    - by conradlee
    I am writing a multi-threaded program using OpenMP in C++. At one point my program forks into many threads, each of which need to add "jobs" to some container that keeps track of all added jobs. Each job can just be a pointer to some object. Basically, I just need the add pointers to some container from several threads at the same time. Is there a simple solution that performs well? After some googling, I found that STL containers are not thread-safe. Some stackoverflow threads address this question, but none that forms a consensus on a simple solution.

    Read the article

  • deleting a file in java while uploading it in other thread

    - by user369507
    i'm trying to build a semi file sharing program, when each computer acts both as a server and as a client. I give multiple threads the option to DL the file from my system. also, i've got a user interface that can recieve a delete message. my problem is that i want that the minute a delete message receieved, i wait for all the threads that are DL the file to finish DL, and ONLY than excute file.delete(). what is the best way to do it? I thought about some database that holds and iterate and check if the thread is active, but it seems clumsy. is there a better way? thanks

    Read the article

  • Tomcat 6 thread safe email queue (javax.mail.*)

    - by Eric V
    Hi I have design/architecture question. I would like to send emails from one of my jsp pages. I have one particular issue that has been a little bit of a problem. there is an instance where one of the pages will need to send around 50 emails at near the same time. I would like the messages sent to a queue where a background thread will actually do the email sending. What is the appropriate way to solve this problem? If you know of a tutorial, example code or tomcat configuration is needed please let me know. Thanks,

    Read the article

  • Lock a mutex multiple times in the same thread

    - by Megacan
    Hi, I'm developing an application on an embedded linux OS (uClinux) and I need to be able to lock the mutex more than once (by the same thread). I have a mutex and a mutexattr defined and initialized as follows: pthread_mutexattr_t waiting_barcode_mutexattr; pthread_mutex_t waiting_barcode_mutex; pthread_mutexattr_init(&waiting_barcode_mutexattr); pthread_mutexattr_settype(&waiting_barcode_mutexattr, PTHREAD_MUTEX_RECURSIVE); pthread_mutex_init(&waiting_barcode_mutex, &waiting_barcode_mutexattr); But when I try to acquire the lock twice it blocks on the second lock: pthread_mutex_lock(&waiting_barcode_mutex); pthread_mutex_lock(&waiting_barcode_mutex); Am I initializing it wrong or is there a better way of accomplishing the same? Thanks in advance.

    Read the article

  • C# regularly return values from a different thread

    - by sdds
    Hello, I'm very new to multithreading and lack experience. I need to compute some data in a different thread so the UI doesn't hang up, and then send the data as it is processed to a table on the main form. So, basically, the user can work with the data that is already computed, while other data is still being processed. What is the best way to achieve this? I would also be very grateful for any examples. Thanks in advance.

    Read the article

  • [C++] Needed: A simple C++ container (stack, linked list) that is thread-safe for writing

    - by conradlee
    I am writing a multi-threaded program using OpenMP in C++. At one point my program forks into many threads, each of which need to add "jobs" to some container that keeps track of all added jobs. Each job can just be a pointer to some object. Basically, I just need the add pointers to some container from several threads at the same time. Is there a simple solution that performs well? After some googling, I found that STL containers are not thread-safe. Some stackoverflow threads address this question, but none form a consensus on a simple solution.

    Read the article

  • Windows service thread not updating database until complete

    - by dfarney
    I have a windows service with a FileSystemWatcher. When a new file is dropped in my folder a new thread is created, started, and I begin processing the file. Throughout this process I am making updates to the database (Linq to SQL) to keep track of the file's processing progress. Problem is none of my database updates are reflected throughout the process, just an update after everything has been completed. Any ideas? Note: when doing dev/testing my code was in an aspx page and worked great, but when I put it in a windows service I no longer get the progress updates. Thanks!

    Read the article

  • Define thread in C++

    - by Vsevywniy
    How do I start a thread using _beginthreadex(), making it execute void myFunction(wchar_t *param);? I try to use this: _beginthread(NULL, 0, myFunction, L"someParam", 0, &ThreadID); but there is compilation error: error C2664: 'beginthreadex' : cannot convert parameter 3 from 'void (_cdecl *)(wchar_t *)' to 'unsigned int (__stdcall *)(void *)'. How I can resolve this error? I seem able to do _beginthread((void(*)(void*))myFunction, 0 , (void *)L"someParam");. But for _beginthreadex() these casts don't seem to work. What do I need to do?

    Read the article

  • Waiting for DialogActivity to return before continuing executing of the main thread

    - by jax
    How would I force the current thread to wait until another has finished before continuing. In my program the user selects a MODE from an AlertDialog, I want to halt executing of the program before continuing as the mode holds important configuration for the gameplay. new AlertDialog.Builder(this) .setItems(R.array.game_modes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { switch (which) { case 0: setMode(TRAINING_MODE); case 1: setMode(QUIZ_MODE); default: setMode(TRAINING_MODE); break; } //continue loading the rest of onCreate(); contineOnCreate(); } }) .create().show(); If this is impossible can anyone give a possible solution?

    Read the article

  • Server Side code Pushing Data to client Browser while current thread is busy Comet (programming)

    - by h_power11
    Hello Friends, I am writing one simple web page with bunch of textboxes and a button control. Now when user finished editing the values on this text boxes user has to click the button and this button invoke heavily process intensive algorithm on server side code based on the data received from client (Textboxes) And it could some time takes up to 30 to 45 minutes to complete the whole operation so the current thread is still inside the button click event handler function. That background task only provides one event, and the web page subscribes to it to get some text data after each stage of processing I was wandering if there is any way I can keep user up-to-date with what is the current progress on that background task. I have div element to print the current status information So I am looking for some sort of reverse mechanism then "get" and "post". I have read some articles on the Comet (programming) but I can't find any easy or definitive answer Thanks in advance

    Read the article

  • How to increase thread-pool threads on IIS 7.0

    - by Xaqron
    Environment: Windows Server 2008 Enterprise, IIS 7.0, ASP.NET 2.0 (CLR), .NET 4.0 I have an ASP.NET application with no page and no session(HttpHandler). It a streaming server. I use two threads for processing each request so if there are 100 connected clients, then 200 threads are used. This is a dedicated server and there's no more application on the server. The problem is after 200 clients are connected (under stress testing) application refuses new clients, but if I increase the worker threads of application pool (create a web garden) then I can have 200 new happy clients per w3wp process. I feel .NET thread pool limit reaches at that point and need to increase it. Thanks

    Read the article

< Previous Page | 57 58 59 60 61 62 63 64 65 66 67 68  | Next Page >