Search Results

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

Page 33/344 | < Previous Page | 29 30 31 32 33 34 35 36 37 38 39 40  | Next Page >

  • Fire just once a Thread in Asp.net WebSite Global.asax

    - by Luís Custódio
    I've a legacy application using Asp.Net WebSite (winforms...) and I need run a background thread that collect periodically some files. But this thread must run just one time! My problem start when I put a method in Application_Start: void Application_Start(object sender, EventArgs e) { SetConnection(); SetNHibernate(); SetNinject(); SetExportThread(); } So I start my application on Visual Studio and three threads start to run. I need some singleton? or something?

    Read the article

  • Visual Studio 2008 Macro for Building does not block thread

    - by Climber104
    Hello, I am trying to write a macro for Building my application, kicking off an external tool, and ataching the debugger to that external tool. Everything is working except for the building. It builds, but it is not blocking the thread so the external tool gets kicked off before it can finish. Is there a way I can run ExecuteCommand and wait for the thread to finish? Code is below: DTE.ExecuteCommand("ClassViewContextMenus.ClassViewProject.Build") DTE.ExecuteCommand("Tools.ExternalCommand11") Try Dim dbg2 As EnvDTE80.Debugger2 = DTE.Debugger Dim trans As EnvDTE80.Transport = dbg2.Transports.Item("Default") Dim dbgeng(1) As EnvDTE80.Engine dbgeng(0) = trans.Engines.Item("Managed") Dim proc2 As EnvDTE80.Process2 = dbg2.GetProcesses(trans, "MINIPC").Item("_nStep.exe") proc2.Attach2(dbgeng) Catch ex As System.Exception MsgBox(ex.Message) End Try

    Read the article

  • Avoding multiple thread spawns in pthreads

    - by madman
    Hi StackOverflow, I have an application that is parallellized using pthreads. The application has a iterative routine call and a thread spawn within the rountine (pthread_create and pthread_join) to parallelize the computation intensive section in the routine. When I use an instrumenting tool like PIN to collect the statistics the tool reports statistics for several threads(no of threads x no of iterations). I beleive it is because it is spawning new set of threads each time the routine is called. How can I ensure that I create the thread only once and all successive calls use the threads that have been created first. When I do the same with OpenMP and then try to collect the statistics, I see that the threads are created only once. Is it beacause of the OpenMP runtime ? Thanks.

    Read the article

  • Using CreateWindow() to make additional Window on a thread - C

    - by Jamie Keeling
    Hello, I have a windows form that has a simple menu and performs a simple operation, I want to be able to create another windows form with all the functionality of a menu bar, message pump etc.. as a separate thread so I can then share the results of the operation to the second window. I.E. 1) Form A opens Form B opens as a separate thread 2)Form A performs operation 3)Form A passes results via memory to Form B 4)Form B display results I'm confused as to how to go about it, the main app runs fine but i'm not sure how to add a second window if the first one already exists. I think that using CreateWindow will allow me to make another window but again i'm not sure how to access the message pump so I can respond to certain events like WM_CREATE on the second window. I hope it makes sense. Thanks!

    Read the article

  • Is it okay to pass injected EntityManagers to EJB bean's helper classes and use it?

    - by Zwei steinen
    We have some JavaEE5 stateless EJB bean that passes the injected EntityManager to its helpers. Is this safe? It has worked well until now, but I found out some Oracle document that states its implementation of EntityManager is thread-safe. Now I wonder whether the reason we did not have issues until now, was only because the implementation we were using happened to be thread-safe (we use Oracle). @Stateless class SomeBean { @PersistenceContext private EntityManager em; private SomeHelper helper; @PostConstruct public void init(){ helper = new SomeHelper(em); } @Override public void business(){ helper.doSomethingWithEm(); } } Actually it makes sense.. If EntityManager is thread-unsafe, a container would have to do inercept business() this.em = newEntityManager(); business(); which will not propagate to its helper classes. If so, what is the best practice in this kind of a situation? Passing EntityManagerFactory instead of EntityManager?

    Read the article

  • How to implement thread timeout in J2ME?

    - by lilo
    I am using Connector in J2ME and found that sometimes it take a very long time to send a request, and sometime it may halt the whole process. So I try to put code related to Connector in a thread and try to set timeout to the thread. But I found out that it's very difficult to do this in J2ME because there's no join(long) in J2ME. Is there any way to do this? Or any better way to deal with network connection in J2ME? Thanks a lot in advance.

    Read the article

  • How does the email header field 'thread-index' work?

    - by Tim
    I was wondering if anyone knew how the thread-index field in email headers work? Here's a simple chain of emails thread indexes that I messaged myself with. Email 1 Thread-Index: AcqvbpKt7QRrdlwaRBKmERImIT9IDg== Email 2 Thread-Index: AcqvbpjOf+21hsPgR4qZeVu9O988Eg== Email 3 Thread-Index: Acqvbp3C811djHLbQ9eTGDmyBL925w== Email 4 Thread-Index: AcqvbqMuifoc5OztR7ei1BLNqFSVvw== Email 5 Thread-Index: AcqvbqfdWWuz4UwLS7arQJX7/XeUvg== I can't seem to say with certainty how I can link these emails together. Normally, I would use the in-reply-to field or references field, but I recently found that Blackberrys do NOT include these fields. The only include Thread-Index field.

    Read the article

  • Android Multithreading, creating new thread not executing rest of OnCreate

    - by Aidan
    Hi Guys, Basically I'm trying to run 2 threads within the same class at the same time. The code runs but only executes whats in run() and doesnt finish the onCreate method... anyone know why? public Camera1(){ t = new Thread(this, "My Thread"); t.start(); } public void run(){ bearing(); } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); new Camera1(); makeview(); tracking(); } Thanks!

    Read the article

  • how to use Thread in java ?

    - by tiendv
    Hi all i have code use googleseach API I want to use Thread to improve speed of my program. But i have a problem here is code import java.io.BufferedReader; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.InputStreamReader; import java.net.URL; import java.net.URLConnection; import java.net.URLEncoder; import java.util.ArrayList; import java.util.Enumeration; import java.util.Hashtable; import java.util.List; import org.json.JSONArray; import org.json.JSONObject; import com.yahoo.search.WebSearchResult; /** * Simple Search using Google ajax Web Services * * @author Daniel Jones Copyright 2006 Daniel Jones Licensed under BSD open * source license http://www.opensource.org/licenses/bsd-license.php */ public class GoogleSearchEngine extends Thread { private String queryString; private int maxResult; private ArrayList<String> resultGoogleArrayList = null; public ArrayList<String> getResultGoogleArrayList() { return resultGoogleArrayList; } public void setResultGoogleArrayList(ArrayList<String> resultGoogleArrayList) { this.resultGoogleArrayList = resultGoogleArrayList; } public String getQueryString() { return queryString; } public void setQueryString(String queryString) { this.queryString = queryString; } public int getMaxResult() { return maxResult; } public void setMaxResult(int maxResult) { this.maxResult = maxResult; } // Put your website here public final static String HTTP_REFERER = "http://www.example.com/"; public static ArrayList<String> makeQuery(String query, int maxResult) { ArrayList<String> finalArray = new ArrayList<String>(); ArrayList<String> returnArray = new ArrayList<String>(); try { query = URLEncoder.encode(query, "UTF-8"); int i = 0; String line = ""; StringBuilder builder = new StringBuilder(); while (true) { // Call GoogleAjaxAPI to submit the query URL url = new URL("http://ajax.googleapis.com/ajax/services/search/web?start=" + i + "&rsz=large&v=1.0&q=" + query); URLConnection connection = url.openConnection(); if (connection == null) { break; } // Value i to stop while or Max result if (i >= maxResult) { break; } connection.addRequestProperty("Referer", HTTP_REFERER); BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream(),"utf-8")); while ((line = reader.readLine()) != null) { builder.append(line); } String response = builder.toString(); JSONObject json = new JSONObject(response); JSONArray ja = json.getJSONObject("responseData").getJSONArray("results"); for (int j = 0; j < ja.length(); j++) { try { JSONObject k = ja.getJSONObject(j); // Break string into 2 parts: URL and Title by <br> returnArray.add(k.getString("url") + "<br>" + k.getString("titleNoFormatting")); } catch (Exception e) { e.printStackTrace(); } } i += 8; } // Remove objects that is over the max number result required if (returnArray.size() > maxResult) { for (int k=0; k<maxResult; k++){ finalArray.add(returnArray.get(k)); } } else return returnArray; return finalArray; } catch (Exception e) { e.printStackTrace(); } return null; } @Override public void run() { // TODO Auto-generated method stub //super.run(); this.resultGoogleArrayList = GoogleSearchEngine.makeQuery(queryString, maxResult); System.out.println("Code run here "); } public static void main(String[] args) { Thread test = new GoogleSearchEngine(); ((GoogleSearchEngine) test).setQueryString("data "); ((GoogleSearchEngine) test).setMaxResult(10); test.start(); ArrayList<String> returnGoogleArrayList = null; returnGoogleArrayList = ((GoogleSearchEngine) test).getResultGoogleArrayList(); System.out.print("contents of al:" + returnGoogleArrayList); } } when i run it, it can run into run method but it don't excute make query methor and return null array. when i do't use Thread it can nomal . Can you give me the reason why ? or give a sulution Thanks

    Read the article

  • NSOperationqueue i want to block main thread

    - by alexeyndru
    i want to block the main thread until something else is done in the background. i used: result=[self performSelectorInBackground:@selector(calculate:) withObject:expression]; just bellow this line I am using result: [self use:result]; i dont want to use result until it is available. to achieve this I implemented calculate: { [[(AppDelegate *)[[UIApplication sharedApplication] delegate] queue] waitUntilAllOperationsAreFinished]; calculating result... } and still, the result is used before it is calculated. so, i didnt block the main thread. pls help me do that. thanks

    Read the article

  • Creating additional Window by a thread - C

    - by Jamie Keeling
    Hello, I have a windows form that has a simple menu and performs a simple operation, I want to be able to create another windows form with all the functionality of a menu bar, message pump etc.. as a separate thread so I can then share the results of the operation to the second window. I.E. 1) Form A opens Form B opens as a separate thread 2)Form A performs operation 3)Form A passes results via memory to Form B 4)Form B display results I'm confused as to how to go about it, the main app runs fine but i'm not sure how to add a second window if the first one already exists. I hope it makes sense. Thanks!

    Read the article

  • How to wait for thread to finish with .NET?

    - by Maxim Z.
    I've never really used threading before in C# where I need to have two threads, as well as the main UI thread. Basically, I have the following. public void StartTheActions() { //Starting thread 1.... Thread t1 = new Thread(new ThreadStart(action1)); t1.Start(); //Now, I want for the main thread (which is calling StartTheActions() ) to wait for t1 to finish (I have created an event in action1() for this) and then start t2... //HOW DO I DO THIS? Thread t2 = new Thread(new ThreadStart(action2)); t2.Start(); } So, essentially, my question is how to have a thread wait for another one to finish. What is the best way to do this? Thanks!

    Read the article

  • In .NET, what thread will Events be handled in?

    - by Ben
    I have attempted to implement a producer/consumer pattern in c#. I have a consumer thread that monitors a shared queue, and a producer thread that places items onto the shared queue. The producer thread is subscribed to receive data...that is, it has an event handler, and just sits around and waits for an OnData event to fire (the data is being sent from a 3rd party api). When it gets the data, it sticks it on the queue so the consumer can handle it. When the OnData event does fire in the producer, I had expected it to be handled by my producer thread. But that doesn't seem to be what is happening. The OnData event seems as if it's being handled on a new thread instead! Is this how .net always works...events are handled on their own thread? Can I control what thread will handle events when they're raised? What if hundreds of events are raised near-simultaneously...would each have its own thread?

    Read the article

  • How to fire off a asych thread in a web application, and gaurantee only 1 thread fires?

    - by Blankman
    I want to cache a object in memory. Regenerating the object when the cache expires is fairly expensive, so I want to do the following: When the cache is "about" to expire, I want to fire off a asychronous thread that will go and rebuild the object and then reset the cache. One thing I am worry about is multiple threads firing to fetch the object to cache, I only want a single thread doing this, realizing many people will be hitting the website. This might not be the best use case to do this, but I want to know how to do this sort of thing.

    Read the article

  • Catch unhandled exception of invisible thread

    - by user346804
    In my C++ application i use an activeX component that runs its own thread (or several I don't know). Sometimes this components throws exceptions. I would like to catch these exceptions and do recovery instead of my entire application crashing. But since I don't have access to its source code or thread I am unsure how it would be done. The only solution I can think of is to run it in its own process. Using something like CreateProcess and then CreateRemoteThread, unsure how it could be implemented. Any suggestion on how to go about solving this?

    Read the article

  • How to use a delay in a swing application

    - by M.R.
    I am building a swing application. At some point, I have to start an "animation": ... jpanel1.setBackground(Color.Black); Delay(milli) jpanel1.setBackground(Color.White); ... and so on. The gui itself and all the logic behind it work.It is just this time depended color-changing that does not. I have read, that swing is not thread safe, but all the examples I found showed me how to start another thread (for example in the background) but never how to stop the current swing-gui thread.

    Read the article

  • Mouse move and thread

    - by bsebi
    When I move the mouse over the window, the program runs much faster (cc. 3 times). This is a real time webcam .Net/Mono application running on a MacBook. On Windows works perfect. Is this maybe a power saving function of the laptop? The code: Thread t = new Thread(Foo); t.Priority = ThreadPriority.Highest; // I've tried without priority too, doesn't matter t.Start(); ... void Foo() { while (true) { ++k; // then write k to the window somehow } }

    Read the article

  • MS Exam 70-536 - How to throw and handle exception from thread?

    - by Max Gontar
    Hello! In MS Exam 70-536 .Net Foundation, Chapter 7 "Threading" in Lesson 1 Creating Threads there is a text: Be aware that because the WorkWithParameter method takes an object, Thread.Start could be called with any object instead of the string it expects. Being careful in choosing your starting method for a thread to deal with unknown types is crucial to good threading code. Instead of blindly casting the method parameter into our string, it is a better practice to test the type of the object, as shown in the following example: ' VB Dim info As String = o as String If info Is Nothing Then Throw InvalidProgramException("Parameter for thread must be a string") End If // C# string info = o as string; if (info == null) { throw InvalidProgramException("Parameter for thread must be a string"); } So, I've tried this but exception is not handled properly (no console exception entry, program is terminated), what is wrong with my code (below)? class Program { static void Main(string[] args) { Thread thread = new Thread(SomeWork); try { thread.Start(null); thread.Join(); } catch (InvalidProgramException ex) { Console.WriteLine(ex.Message); } finally { Console.ReadKey(); } } private static void SomeWork(Object o) { String value = (String)o; if (value == null) { throw new InvalidProgramException("Parameter for "+ "thread must be a string"); } } } Thanks for your time!

    Read the article

  • Command Not working in separate thread in J2me.

    - by RishiPatel
    I am creating a bluetooth application. I created a simple midlet with a exit command and i create a thread for finding the service and discovering the device. While doing so it displays a animated screen on which i added the parent commandListener for exit command. After successful connection both user is represented with greetings(Current screen calls the parent Display method setCurrent for displaying itself). This screen also have CommandListener set to the parent. Now i want to add few more commands. I Implemented the CommandLIstener Interface in this class, added few commands but the commands are not working. I dont whats wen wrong. I am giving u Code snippets to fully describle my issue : - package name Imports here public class MyMidlet extends MIDlet implements CommandListener { public CommandListener theListener; public Display theDisplay; public Command exitCommand; public MyMidlet() { // Retrieve the display for this MIDlet //Create the initial screen } public void startApp() throws MIDletStateChangeException { } public void pauseApp() { } public void destroyApp(boolean unconditional) { } public void commandAction(Command c, Displayable d) { // Determine if the exit command was selected if (c == exitCommand) { //End application here notifyDestroyed(); } else { //Start the new thread here } } } Now here is the code for the class which is invoked by the above midlet in a separate thread; package here; imports here public class MyService implements Runnable, CommandListener { private MyMidlet parent; private StreamConnection conn; private OutputStream output; private InputStream input; public Command sendCommand; private TextField messageToSend Form form; public BChatService(boolean isServer, BChatMidlet parent) { //some stuff here this.parent = parent; } public void run() { //functino for showing animation here try { input = conn.openInputStream(); output = conn.openOutputStream(); } catch (IOException e) { displayError("IO Error", "An error occurred while opening " + "the input and output streams" + "(IOException: " + e.getMessage() + ")"); try { conn.close(); } catch (Exception ex) { } return; } // Create the Form here when service is discoverd and greets the users Command sendCommand = new Command("Send", Command.ITEM, 2); exitCommand = new Command("Exit", Command.EXIT, 1); form.addCommand(exitCommand); form.addCommand(sendCommand); parent.theDisplay.setCurrent(form); form.setCommandListener(this); public void commandAction(Command c, Displayable d) { if (c == exitCommand) { // End the game parent.destroyApp(true); parent.notifyDestroyed(); } if(c == sendCommand) { form.append("SOme text here"); } } } When i select the Send command, the string doesnt append in form neither exit command works. What can be the possible cause for it?? I need to implement this functionality...Is there any other way to achieve this??

    Read the article

  • java.lang.OutOfMemoryError: unable to create new native thread for multiple threads

    - by Kaustubh Ranjan Singh
    static class solver implements Runnable { static calculator(problem){ //Some code if(condition) {solver s = new solver(newproblem); new Thread(s).start();} } Public solver(int newproblem) { this.problem = newproblem ; } public void run() { // TODO Auto-generated method stub calculator(promblem); } } i am having a big array maze of 100x100 and i am trying to solve it and i am getting an error java.lang.OutOfMemoryError: unable to create new native thread(after running a code for some times). How can solve this , How can i use ExecutorService i think that will solve the problem or i want something like thisIf Number of generated threads4K then stop the first 100 threads

    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

  • Parent Thread exiting before Child Threads [python]

    - by crgwbr
    I'm using Python in a webapp (CGI for testing, FastCGI for production) that needs to send an occasional email (when a user registers or something else important happens). Since communicating with an SMTP server takes a long time, I'd like to spawn a thread for the mail function so that the rest of the app can finish up the request without waiting for the email to finish sending. I tried using thread.start_new(func, (args)), but the Parent return's and exits before the sending is complete, thereby killing the sending process before it does anything useful. Is there anyway to keep the process alive long enough for the child process to finish?

    Read the article

< Previous Page | 29 30 31 32 33 34 35 36 37 38 39 40  | Next Page >