Search Results

Search found 8588 results on 344 pages for 'thread abort'.

Page 137/344 | < Previous Page | 133 134 135 136 137 138 139 140 141 142 143 144  | Next Page >

  • Android: how to update UI dynamically?

    - by pandre
    I have an Android app and I need to change UI dynamically: ex: when user presses a button, I want to change the current activity's views and, as in some cases there are a lot of views involved, I need to display a ProgressDialog. I have been using an AsyncTask, but I think that it is not the best solution, because AsyncTask's doInBackground runs a different thread, so I can't update UI from there - I have to use runOnUiThread, which runs the code in the UI Thread, but freezes the progress dialog that is shown. I guess there should be more people with similar issues, as updating UI while displaying a ProgressDialog seems to be something done regularly by applications. So does anyone have a solution to this?

    Read the article

  • C++ WIN32: Short multitasking example

    - by Con Current
    I searched for examples on how to create a simple multithreaded app that does something similar to this: #include <iostream> using namespace std; int myConcurrentFunction( ) { while( 1 ) { cout << "b" << endl; } } int main( ) { // Start a new thread for myConcurrentFunction while( 1 ) { cout << "a" << endl; } } How can I get the above to output a and b "randomly" by starting a new thread instead of just calling myConcurrentFunction normally? I mean: What is the minimal code for it? Is it really only one function I have to call? What files do I need to include? I use MSVC 2010, Win32

    Read the article

  • c++ multithread array

    - by user1731972
    i'm doing something for fun, trying to learn multithreading Problems passing array by reference to threads but Arno pointed out that my threading via process.h wasn't going to be multi-threaded. What I'm hoping to do is something where I have an array of 100 (or 10,000, doesn't really matter I don't think), and split up the assignment of values to each thread. Example, 4 threads = 250 values per thread to be assigned. Then I can use this filled array for further calculations. Here's some code I was working on (which doesn't work) #include <process.h> #include <windows.h> #include <iostream> #include <fstream> #include <time.h> //#include <thread> using namespace std; void myThread (void *dummy ); CRITICAL_SECTION cs1,cs2; // global int main() { ofstream myfile; myfile.open ("coinToss.csv"); int rNum; long numRuns; long count = 0; int divisor = 1; float holder = 0; int counter = 0; float percent = 0.0; HANDLE hThread[1000]; int array[10000]; srand ( time(NULL) ); printf ("Runs (use multiple of 10)? "); cin >> numRuns; for (int i = 0; i < numRuns; i++) { //_beginthread( myThread, 0, (void *) (array1) ); //??? //hThread[i * 2] = _beginthread( myThread, 0, (void *) (array1) ); hThread[i*2] = _beginthread( myThread, 0, (void *) (array) ); } //WaitForMultipleObjects(numRuns * 2, hThread, TRUE, INFINITE); WaitForMultipleObjects(numRuns, hThread, TRUE, INFINITE); } void myThread (void *param ) { //thanks goes to stockoverflow //http://stackoverflow.com/questions/12801862/problems-passing-array-by-reference-to-threads int *i = (int *)param; for (int x = 0; x < 1000000; x++) { //param[x] = rand() % 2 + 1; i[x] = rand() % 2 + 1; } } Can anyone explain why it isn't working?

    Read the article

  • YouTube app fails to open up when launched.

    - by user354738
    Below logs gives any clue ? The app just opens up (we could just see the tite of the app as YouTube and it goes back to launcher tray immd.) cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.google.android.youtube/.HomeActivity } 05-31 14:06:41.655: INFO/ActivityManager(1102): Start proc com.google.android.youtube for activity com.google.android.youtube/.HomeActivity: pid=2977 uid=10041 gids={3003} 05-31 14:06:41.655: DEBUG/KeyguardViewMediator(1102): setHidden false 05-31 14:06:41.796: INFO/foo(1102): ********************** resuming: 1144012408 05-31 14:06:41.897: INFO/ActivityThread(2977): Publishing provider com.google.android.youtube.SuggestionProvider: com.google.android.youtube.suggest.SuggestionProvider 05-31 14:06:41.960: INFO/YouTube(2977): Distribution channel:mvapp-android-google 05-31 14:06:42.116: INFO/AndroidRuntime(2977): AndroidRuntime onExit calling exit(-42) 05-31 14:06:42.116: INFO/dalvikvm(2977): In threadExitCheck 0xbdb0 05-31 14:06:42.116: ERROR/dalvikvm(2977): Native thread exited without telling us 05-31 14:06:42.116: ERROR/dalvikvm(2977): Native thread 2977 status: 7 05-31 14:06:42.124: DEBUG/KeyguardViewMediator(1102): setHidden false 05-31 14:06:42.139: INFO/ActivityManager(1102): Process com.google.android.youtube (pid 2977) has died

    Read the article

  • Java process problem in Eclipse

    - by Norbi
    Hi! This is my code: final String run_tool ="cmd.exe /C pelda.exe"; final Process tool_proc = null; Runnable doRun = new Runnable() { public void run() { try { tool_proc = Runtime.getRuntime().exec(run_tool); } catch (IOException e) { e.printStackTrace(); } } }; Thread th = new Thread(doRun); th.start(); InputStream toolstr = tool_proc.getInputStream(); After the eclipse gives this warning message fot the tool_proc variable: The final local variable tool_proc cannot be assigned, since it is defined in an enclosing type I dont't know why my code doesn't work please help me

    Read the article

  • C# What would happen to GC if I run process with priority = RealTime?

    - by Bobb
    I have a C# app which runs with priority RealTime. It was all fine until I made few hectic changes in past 2 days. Now it runs out of memory in few hours. I am trying to find whether it is a memory leak I created of this is because I consume lot more objects than before and GC simply cant collect them because it runs with same priority. My question is - what could happen to GC when it tries to collect objects in application with RealTime priority (there is also at least one thread running with Highest thread priority)? (P.S. by realtime priority I mean Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.RealTime)

    Read the article

  • Why might someone say R is *NOT* a programming language? [closed]

    - by Tal Galili
    I came by the following comment today on twitter "R is not a programming language, it's a statistics package with the GUI missing." And I am wondering - Why not? What is "missing" in R to make it a "programming language" ? Update: For the protocol, I am a big fan of R, use it daily, and support it's existence. I now changed the name of this thread from "Why is R NOT a programming language?" to "Why might someone say R is NOT a programming language?" Which better reflects my motivation for this thread (which is, to know if R has any programmatical disadvantages that I might have not heard about).

    Read the article

  • Simple prime number program - Weird issue with threads C#

    - by Para
    Hi! This is my code: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; namespace FirePrime { class Program { static bool[] ThreadsFinished; static bool[] nums; static bool AllThreadsFinished() { bool allThreadsFinished = false; foreach (var threadFinished in ThreadsFinished) { allThreadsFinished &= threadFinished; } return allThreadsFinished; } static bool isPrime(int n) { if (n < 2) { return false; } if (n == 2) { return true; } if (n % 2 == 0) { return false; } int d = 3; while (d * d <= n) { if (n % d == 0) { return false; } d += 2; } return true; } static void MarkPrimes(int startNumber,int stopNumber,int ThreadNr) { for (int j = startNumber; j < stopNumber; j++) nums[j] = isPrime(j); lock (typeof(Program)) { ThreadsFinished[ThreadNr] = true; } } static void Main(string[] args) { int nrNums = 100; int nrThreads = 10; //var threadStartNums = new List<int>(); ThreadsFinished = new bool[nrThreads]; nums = new bool[nrNums]; //var nums = new List<bool>(); nums[0] = false; nums[1] = false; for(int i=2;i<nrNums;i++) nums[i] = true; int interval = (int)(nrNums / nrThreads); //threadStartNums.Add(2); //int aux = firstStartNum; //int i = 2; //while (aux < interval) //{ // aux = interval*i; // i=i+1; // threadStartNums.Add(aux); //} int startNum = 0; for (int i = 0; i < nrThreads; i++) { var _thread = new System.Threading.Thread(() => MarkPrimes(startNum, Math.Min(startNum + interval, nrNums), i)); startNum = startNum + interval; //set the thread to run in the background _thread.IsBackground = true; //start our thread _thread.Start(); } while (!AllThreadsFinished()) { Thread.Sleep(1); } for (int i = 0; i < nrNums; i++) if(nums[i]) Console.WriteLine(i); } } } This should be a pretty simple program that is supposed to find and output the first nrNums prime numbers using nrThreads threads working in parallel. So, I just split nrNums into nrThreads equal chunks (well, the last one won't be equal; if nrThreads doesn't divide by nrNums, it will also contain the remainder, of course). I start nrThreads threads. They all test each number in their respective chunk and see if it is prime or not; they mark everything out in a bool array that keeps a tab on all the primes. The threads all turn a specific element in another boolean array ThreadsFinished to true when they finish. Now the weird part begins: The threads never all end. If I debug, I find that ThreadNr is not what I assign to it in the loop but another value. I guess this is normal since the threads execute afterwards and the counter (the variable i) is already increased by then but I cannot understand how to make the code be right. Can anyone help? Thank you in advance. P.S.: I know the algorithm is not very efficient; I am aiming at a solution using the sieve of Eratosthenes also with x given threads. But for now I can't even get this one to work and I haven't found any examples of any implementations of that algorithm anywhere in a language that I can understand.

    Read the article

  • Rewrite code from Threads to AnyEvent

    - by user1779868
    I wrote a code: use LWP::UserAgent; use HTTP::Cookies; use threads; use threads::shared; $| = 1; $threads = 50; my @urls : shared = loadf('url.txt'); my @thread_list = (); $thread_list[$_] = threads->create(\&thread) for 0 .. $threads - 1; $_->join for @thread_list; thread(); sub thread { my ($web, $ck) = browser(); while(1) { my $url = shift @urls; if(!$url) { last; } $code = $web->get($url)->code; print "[+] $url - code: $code\n"; if($code == 200) { open F, ">>200.txt"; print F $url."\n"; close F; } elsif($code == 301) { open F, ">>301.txt"; print F $url."\n"; close F; } else { open F, ">>else.txt"; print F "$url code - $code\n"; close F; } } } sub loadf { open (F, "<".$_[0]) or erroropen($_[0]); chomp(my @data = <F>); close F; return @data; } sub browser { my $web = new LWP::UserAgent; my $ck = new HTTP::Cookies; $web->cookie_jar($ck); $web->agent('Opera/9.80 (Windows 7; U; en) Presto/2.9.168 Version/11.50'); $web->timeout(5); return $web, $ck; } After its working for some time physical storage is full. Can u help me to re-write it with AnyEvent. I tried but my code didn't work. I read that it will help me to safe some memory. Thanks a lot to any helpers.

    Read the article

  • How do I download an attachment from an annotation using client-side JScript?

    - by VVander
    I'm trying to provide a link to the attachment of a note through the client-side JScript. The standard MS-made Notes component does this through the following url: [serverurl]/[appname]/Activities/Attachment/download.aspx?AttachmentType=5&AttachmentId={blahblahblah}&IsNotesTabAttachment=1&CRMWRPCToken=blahblahblah&CRMWRPCTokenTimeStamp=blahblahblah The problem is that I don't know how to get the Token or TokenTimeStamp, so I'm receiving an Access Denied error ("form is no longer available, security precaution, etc"). The only other way I can think of doing this is through the OData endpoint, but that would at best get me a base64 string that I still would have translate into a filestream to give to the browser (all of which seems like it would take forever to implement/figure out). I've found a few other posts that describe the same thing, but no one has answered them: http://social.microsoft.com/Forums/en-US/crmdevelopment/thread/6eb9e0d4-0c0c-4769-ab36-345fbfc9754f/ http://social.microsoft.com/Forums/is/crm/thread/45dabb6e-1c6c-4cb4-85a4-261fa58c04da

    Read the article

  • MySQL Config File for Large System

    - by Jonathon
    We are running MySQL on a Windows 2003 Server Enterpise Edition box. MySQL is about the only program running on the box. We have approx. 8 slaves replicated to it, but my understanding is that having multiple slaves connecting to the same master does not significantly slow down performance, if at all. The master server has 16G RAM, 10 Terabyte drives in RAID 10, and four dual-core processors. From what I have seen from other sites, we have a really robust machine as our master db server. We just upgraded from a machine with only 4G RAM, but with similar hard drives, RAID, etc. It also ran Apache on it, so it was our db server and our application server. It was getting a little slow, so we split the db server onto this new machine and kept the application server on the first machine. We also distributed the application load amongst a few of our other slave servers, which also run the application. The problem is the new db server has mysqld.exe consuming 95-100% of CPU almost all the time and is really causing the app to run slowly. I know we have several queries and table structures that could be better optimized, but since they worked okay on the older, smaller server, I assume that our my.ini (MySQL config) file is not properly configured. Most of what I see on the net is for setting config files on small machines, so can anyone help me get the my.ini file correct for a large dedicated machine like ours? I just don't see how mysqld could get so bogged down! FYI: We have about 100 queries per second. We only use MyISAM tables, so skip-innodb is set in the ini file. And yes, I know it is reading the ini file correctly because I can change some settings (like the server-id and it will kill the server at startup). Here is the my.ini file: #MySQL Server Instance Configuration File # ---------------------------------------------------------------------- # Generated by the MySQL Server Instance Configuration Wizard # # # Installation Instructions # ---------------------------------------------------------------------- # # On Linux you can copy this file to /etc/my.cnf to set global options, # mysql-data-dir/my.cnf to set server-specific options # (@localstatedir@ for this installation) or to # ~/.my.cnf to set user-specific options. # # On Windows you should keep this file in the installation directory # of your server (e.g. C:\Program Files\MySQL\MySQL Server X.Y). To # make sure the server reads the config file use the startup option # "--defaults-file". # # To run run the server from the command line, execute this in a # command line shell, e.g. # mysqld --defaults-file="C:\Program Files\MySQL\MySQL Server X.Y\my.ini" # # To install the server as a Windows service manually, execute this in a # command line shell, e.g. # mysqld --install MySQLXY --defaults-file="C:\Program Files\MySQL\MySQL Server X.Y\my.ini" # # And then execute this in a command line shell to start the server, e.g. # net start MySQLXY # # # Guildlines for editing this file # ---------------------------------------------------------------------- # # In this file, you can use all long options that the program supports. # If you want to know the options a program supports, start the program # with the "--help" option. # # More detailed information about the individual options can also be # found in the manual. # # # CLIENT SECTION # ---------------------------------------------------------------------- # # The following options will be read by MySQL client applications. # Note that only client applications shipped by MySQL are guaranteed # to read this section. If you want your own MySQL client program to # honor these values, you need to specify it as an option during the # MySQL client library initialization. # [client] port=3306 [mysql] default-character-set=latin1 # SERVER SECTION # ---------------------------------------------------------------------- # # The following options will be read by the MySQL Server. Make sure that # you have installed the server correctly (see above) so it reads this # file. # [mysqld] # The TCP/IP Port the MySQL Server will listen on port=3306 #Path to installation directory. All paths are usually resolved relative to this. basedir="D:/MySQL/" #Path to the database root datadir="D:/MySQL/data" # The default character set that will be used when a new schema or table is # created and no character set is defined default-character-set=latin1 # The default storage engine that will be used when create new tables when default-storage-engine=MYISAM # Set the SQL mode to strict #sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION" # we changed this because there are a couple of queries that can get blocked otherwise sql-mode="" #performance configs skip-locking max_allowed_packet = 1M table_open_cache = 512 # The maximum amount of concurrent sessions the MySQL server will # allow. One of these connections will be reserved for a user with # SUPER privileges to allow the administrator to login even if the # connection limit has been reached. max_connections=1510 # Query cache is used to cache SELECT results and later return them # without actual executing the same query once again. Having the query # cache enabled may result in significant speed improvements, if your # have a lot of identical queries and rarely changing tables. See the # "Qcache_lowmem_prunes" status variable to check if the current value # is high enough for your load. # Note: In case your tables change very often or if your queries are # textually different every time, the query cache may result in a # slowdown instead of a performance improvement. query_cache_size=168M # The number of open tables for all threads. Increasing this value # increases the number of file descriptors that mysqld requires. # Therefore you have to make sure to set the amount of open files # allowed to at least 4096 in the variable "open-files-limit" in # section [mysqld_safe] table_cache=3020 # Maximum size for internal (in-memory) temporary tables. If a table # grows larger than this value, it is automatically converted to disk # based table This limitation is for a single table. There can be many # of them. tmp_table_size=30M # How many threads we should keep in a cache for reuse. When a client # disconnects, the client's threads are put in the cache if there aren't # more than thread_cache_size threads from before. This greatly reduces # the amount of thread creations needed if you have a lot of new # connections. (Normally this doesn't give a notable performance # improvement if you have a good thread implementation.) thread_cache_size=64 #*** MyISAM Specific options # The maximum size of the temporary file MySQL is allowed to use while # recreating the index (during REPAIR, ALTER TABLE or LOAD DATA INFILE. # If the file-size would be bigger than this, the index will be created # through the key cache (which is slower). myisam_max_sort_file_size=100G # If the temporary file used for fast index creation would be bigger # than using the key cache by the amount specified here, then prefer the # key cache method. This is mainly used to force long character keys in # large tables to use the slower key cache method to create the index. myisam_sort_buffer_size=64M # Size of the Key Buffer, used to cache index blocks for MyISAM tables. # Do not set it larger than 30% of your available memory, as some memory # is also required by the OS to cache rows. Even if you're not using # MyISAM tables, you should still set it to 8-64M as it will also be # used for internal temporary disk tables. key_buffer_size=3072M # Size of the buffer used for doing full table scans of MyISAM tables. # Allocated per thread, if a full scan is needed. read_buffer_size=2M read_rnd_buffer_size=8M # This buffer is allocated when MySQL needs to rebuild the index in # REPAIR, OPTIMZE, ALTER table statements as well as in LOAD DATA INFILE # into an empty table. It is allocated per thread so be careful with # large settings. sort_buffer_size=2M #*** INNODB Specific options *** innodb_data_home_dir="D:/MySQL InnoDB Datafiles/" # Use this option if you have a MySQL server with InnoDB support enabled # but you do not plan to use it. This will save memory and disk space # and speed up some things. skip-innodb # Additional memory pool that is used by InnoDB to store metadata # information. If InnoDB requires more memory for this purpose it will # start to allocate it from the OS. As this is fast enough on most # recent operating systems, you normally do not need to change this # value. SHOW INNODB STATUS will display the current amount used. innodb_additional_mem_pool_size=11M # If set to 1, InnoDB will flush (fsync) the transaction logs to the # disk at each commit, which offers full ACID behavior. If you are # willing to compromise this safety, and you are running small # transactions, you may set this to 0 or 2 to reduce disk I/O to the # logs. Value 0 means that the log is only written to the log file and # the log file flushed to disk approximately once per second. Value 2 # means the log is written to the log file at each commit, but the log # file is only flushed to disk approximately once per second. innodb_flush_log_at_trx_commit=1 # The size of the buffer InnoDB uses for buffering log data. As soon as # it is full, InnoDB will have to flush it to disk. As it is flushed # once per second anyway, it does not make sense to have it very large # (even with long transactions). innodb_log_buffer_size=6M # InnoDB, unlike MyISAM, uses a buffer pool to cache both indexes and # row data. The bigger you set this the less disk I/O is needed to # access data in tables. On a dedicated database server you may set this # parameter up to 80% of the machine physical memory size. Do not set it # too large, though, because competition of the physical memory may # cause paging in the operating system. Note that on 32bit systems you # might be limited to 2-3.5G of user level memory per process, so do not # set it too high. innodb_buffer_pool_size=500M # Size of each log file in a log group. You should set the combined size # of log files to about 25%-100% of your buffer pool size to avoid # unneeded buffer pool flush activity on log file overwrite. However, # note that a larger logfile size will increase the time needed for the # recovery process. innodb_log_file_size=100M # Number of threads allowed inside the InnoDB kernel. The optimal value # depends highly on the application, hardware as well as the OS # scheduler properties. A too high value may lead to thread thrashing. innodb_thread_concurrency=10 #replication settings (this is the master) log-bin=log server-id = 1 Thanks for all the help. It is greatly appreciated.

    Read the article

  • OpenGL "out of memory" on glReadPixels()

    - by spurserh
    Hello, I am running into an "out of memory" error from OpenGL on glReadPixels() under low-memory conditions. I am writing a plug-in to a program that has a robust heap mechanism for such situations, but I have no idea whether or how OpenGL could be made to use it for application memory management. The notion that this is even possible came to my attention through this [albeit dated] thread on a similar issue under Mac OS X: http://lists.apple.com/archives/Mac-opengl/2001/Sep/msg00042.html I am using Windows XP, and have seen it on multiple NVidia cards. I am also interested in any work-arounds I might be able to relay to users (the thread mentions "increasing virtual memory"). Thanks, Sean

    Read the article

  • YouTube app failes to open up when launched.

    - by user354738
    Below logs gives any clue ? The app just opens up (we could just see the tite of the app as YouTube and it goes back to launcher tray immd.) cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.google.android.youtube/.HomeActivity } 05-31 14:06:41.655: INFO/ActivityManager(1102): Start proc com.google.android.youtube for activity com.google.android.youtube/.HomeActivity: pid=2977 uid=10041 gids={3003} 05-31 14:06:41.655: DEBUG/KeyguardViewMediator(1102): setHidden false 05-31 14:06:41.796: INFO/foo(1102): ********** resuming: 1144012408 05-31 14:06:41.897: INFO/ActivityThread(2977): Publishing provider com.google.android.youtube.SuggestionProvider: com.google.android.youtube.suggest.SuggestionProvider 05-31 14:06:41.960: INFO/YouTube(2977): Distribution channel:mvapp-android-google 05-31 14:06:42.116: INFO/AndroidRuntime(2977): AndroidRuntime onExit calling exit(-42) 05-31 14:06:42.116: INFO/dalvikvm(2977): In threadExitCheck 0xbdb0 05-31 14:06:42.116: ERROR/dalvikvm(2977): Native thread exited without telling us 05-31 14:06:42.116: ERROR/dalvikvm(2977): Native thread 2977 status: 7 05-31 14:06:42.124: DEBUG/KeyguardViewMediator(1102): setHidden false 05-31 14:06:42.139: INFO/ActivityManager(1102): Process com.google.android.youtube (pid 2977) has died

    Read the article

  • Is it possible to create a jdbc connection without a password (using postgresql 'trust')?

    - by mojones
    I am using jdbc to connect to a postgresql database in a java application (actually the app is written in Groovy). I have postgresql set up to use the 'trust' authentication method. Is it possible to open a jdbc connection without specifying a password? When I try to use the normal constructor with a blank password, it fails with Exception in thread "Thread-2" org.postgresql.util.PSQLException: FATAL: password authentication failed for user "myuser" Even though, from the command line, this works fine psql -U myuser mydatabase Welcome to psql 8.3.5, the PostgreSQL interactive terminal. Type: \copyright for distribution terms \h for help with SQL commands \? for help with psql commands \g or terminate with semicolon to execute query \q to quit

    Read the article

  • getting usb com port

    - by I__
    i have this function: private string GetUSBComPort() { string[] sPorts = SerialPort.GetPortNames(); foreach (string port in sPorts) { if (port != "COM1" && port != "COM4") { return port; } } return null; } this function is being called from form load: private void Form1_Load(object sender, EventArgs e) { serialPort1 = new SerialPort(GetUSBComPort()); if (serialPort1.IsOpen) { serialPort1.Close(); } serialPort1.Open(); //ThreadStart myThreadDelegate = new ThreadStart(ReceiveAndOutput); //Thread myThread = new Thread(myThreadDelegate); //myThread.Start(); this.serialPort1.DataReceived += new SerialDataReceivedEventHandler(sp_DataReceived); } the function is unfortunately returning null how do i get the com port to which my phone is attached to via USB?

    Read the article

  • Performing periodic audits and best practice

    - by DTown
    I'm doing a windows form and would like an audit task to happen every 30 seconds. This audit is essentially checking a series of services on remote computers and reporting back into a richtextbox the status. Current I have this running in an endless background thread and using an invoker to update the richtextbox in the main form. Is this best practice? If I made an endless loop in my main form that would prevent any of my buttons from working, correct? I'm just curious if every time I want to create a periodic audit check I have to create a new thread which checks the status or file or what have you?

    Read the article

  • How can I tell that a NetTcp-based WCF connection was interrupted?

    - by mafutrct
    A WCF service is based on NetTcpBinding. It may happen that the client silently vanishes, leaving the server thinking that it is still connected. I'm currently using a thread that pings all connected client to see if they are still alive, and removes disconnected clients. Is a ping thread the correct way to solve the issue, or is there a better, possibly event-based way? Do I have to surround every code that communicates with the client by try/catch and remove it from the list of connected clients additionally?

    Read the article

  • Android game goes blank after pressing home and restarting

    - by sirconnorstack
    I am making an Android game with an Activity called Game, a SurfaceView called GameView and a Thread called GameThread. The Game's onCreate(), I make a new GameView, which makes a new GameThread, where all the game logic and canvas drawing is carried out. However, I'm having some lifecycle difficulties. When I press back and restart it, it works fine, but when I press home and restart it, all I see is a blank screen. Here are the GameView's onSurfaceCreated() and onSurfaceDestroyed(): @Override public void surfaceCreated(SurfaceHolder holder) { mThread.mRunning = true; mThread.mWidth = getWidth(); if(mThread.mWidth > 550) mThread.mWidth = 550; mThread.mHeight = getHeight(); try { mThread.start(); } catch(IllegalThreadStateException e) { } } @Override public void surfaceDestroyed(SurfaceHolder holder) { // Wait for the secondary thread to end before finishing boolean retry = true; mThread.mRunning = false; while (retry) { try { mThread.join(); retry = false; } catch (InterruptedException e) { } } }

    Read the article

  • Multi-threading concept and lock in c#

    - by Neeraj
    I read about lock, though not understood nothing at all. My question is why do we use a un-used object and lock that and how this makes something thread-safe or how this helps in multi-threading ? Isn't there other way to make thread-safe code. public class test { private object Lock { get; set; } ... lock (this.Lock) { ... } ... } Sorry is my question is very stupid, but i don't understand, although i've used it many times.

    Read the article

  • Image animation stops on minimizing and restoring

    - by lc
    I have a .NET WinForms application with an animated GIF in a PictureBox. It's a loading animation, shown while a BackgroundWorker does some processing in another thread. I load the image by setting the Image property and it animates on its own. All is fine until I minimize and restore the application. At which point, the image stops animating and just displays whatever frame it was last on. Note that: The background thread still runs fine and none of the "business" of the application is affected. Subsequently-displayed animated GIFs do work fine (unless the application is minimized again). Does anyone know what causes this problem? Any workarounds?

    Read the article

  • Disable the Go button in the Keyboard for a UITextfield in iphone app.

    - by coder net
    Hi, My app has a screen where keyboard is always visible. The main element of the screen is a UITextfield. For easy data entering, keyboard is always made visible. When the user finishes entering data and hits Go, the app performs a 4,5 seconds action which is done in the background thread in order to show UIActivityIndicatorView. My problem is that the Go button on the keyboard still shows as enabled since the logic is performed in the background. The user could potentially hit the Go again causing it to run again. I am not able to set editable/userinteraction properties to No because then the keyboard disappears. Is there anyway just to disable the Go button or freeze the keyboard until the background thread returns?

    Read the article

  • Solve a maze using multicores?

    - by acidzombie24
    This question is messy, i dont need a working solution, i need some psuedo code. How would i solve this maze? This is a homework question. I have to get from point green to red. At every fork i need to 'spawn a thread' and go that direction. I need to figure out how to get to red but i am unsure how to avoid paths i already have taken (finishing with any path is ok, i am just not allowed to go in circles). Heres an example of my problem, i start by moving down and i see a fork so one goes right and one goes down (or this thread can take it, it doesnt matter). Now lets ignore the rest of the forks and say the one going right hits the wall, goes down, hits the wall and goes left, then goes up. The other thread goes down, hits the wall then goes all the way right. The bottom path has been taken twice, by starting at different sides. How do i mark this path has been taken? Do i need a lock? Is this the only way? Is there a lockless solution? Implementation wise i was thinking i could have the maze something like this. I dont like the solution because there is a LOT of locking (assuming i lock before each read and write of the haveTraverse member). I dont need to use the MazeSegment class below, i just wrote it up as an example. I am allowed to construct the maze however i want. I was thinking maybe the solution requires no connecting paths and thats hassling me. Maybe i could split the map up instead of using the format below (which is easy to read and understand). But if i knew how to split it up i would know how to walk it thus the problem. How do i walk this maze efficiently? The only hint i receive was dont try to conserve memory by reusing it, make copies. However that was related to a problem with ordering a list and i dont think the hint was a hint for this. class MazeSegment { enum Direction { up, down, left, right} List<Pair<Direction, MazeSegment*>> ConnectingPaths; int line_length; bool haveTraverse; } MazeSegment root; class MazeSegment { enum Direction { up, down, left, right} List<Pair<Direction, MazeSegment*>> ConnectingPaths; bool haveTraverse; } void WalkPath(MazeSegment segment) { if(segment.haveTraverse) return; segment.haveTraverse = true; foreach(var v in segment) { if(v.haveTraverse == false) spawn_thread(v); } } WalkPath(root);

    Read the article

  • Best way to reuse a Runnable

    - by Gandalf
    I have a class that implements Runnable and am currently using an Executor as my thread pool to run tasks (indexing documents into Lucene). executor.execute(new LuceneDocIndexer(doc, writer)); My issue is that my Runnable class creates many Lucene Field objects and I would rather reuse them then create new ones every call. What's the best way to reuse these objects (Field objects are not thread safe so I cannot simple make them static) - should I create my own ThreadFactory? I notice that after a while the program starts to degrade drastically and the only thing I can think of is it's GC overhead. I am currently trying to profile the project to be sure this is even an issue - but for now lets just assume it is.

    Read the article

  • memcpy() safety on adjacent memory regions

    - by JaredC
    I recently asked a question on using volatile and was directed to read some very informative articles from Intel and others discussing memory barriers and their uses. After reading these articles I have become quite paranoid though. I have a 64-bit machine. Is it safe to memcpy into adjacent, non-overlapping regions of memory from multiple threads? For example, say I have a buffer: char buff[10]; Is it always safe for one thread to memcpy into the first 5 bytes while a second thread copies into the last 5 bytes? My gut reaction (and some simple tests) indicate that this is completely safe, but I have been unable to find documentation anywhere that can completely convince me.

    Read the article

< Previous Page | 133 134 135 136 137 138 139 140 141 142 143 144  | Next Page >