while-loop

Form freezes during while loop

纵饮孤独 提交于 2019-12-21 03:00:51
问题 I have a piece of code that checks if a certain application is running while (Process.GetProcessesByName("notepad").Length == 0) { System.Threading.Thread.Sleep(1000); } It will check if the user is running notepad but it makes the form freeze and stop responding after a few seconds. I don't know if there is a better solution to fix this problem. 回答1: In this case, you actually want some work done on a thread that's separate from your main UI thread. The ideal scenario would be to leverage

bash while loop threading

半腔热情 提交于 2019-12-21 01:28:07
问题 i have a while loop reading lines from a $hosts while read line do ip=$line check done < $hosts my question is can I use some way to speed this up or run the check on 10 hosts at a time and each check is on a different IP and finish when all IP in $host have been checked? Thanks 回答1: You can send tasks to the background by & If you intend to wait for all of them to finish you can use the wait command: process_to_background & echo Processing ... wait echo Done You can get the pid of the given

Basic multiprocessing with while loop

南楼画角 提交于 2019-12-20 19:47:11
问题 I am brand new to the multiprocessing package in python and my confusion will probably be easy for someone who knows more to clear up. I've been reading about concurrency and have searched for other questions like this and have found nothing. (FYI I do NOT want to use multithreading because the GIL will slow down my application a lot.) I am thinking in the framework of events. I want to have multiple processes running, waiting for an event to happen. If the event happens, it gets assigned to

Comma Separated List of all columns in the Database (Tablename | Column_names…)

爱⌒轻易说出口 提交于 2019-12-20 12:40:46
问题 In SQL Server, I would like see Table_Name and all the Columns associated with that Table_Name in a database. So the Output should look like this: TABLE_NAME COLUMN_NAME 1. Employee Employee-id, Lastname, Firstname, Title........... 2. Orders Orderid, Order-date, shipped-date, delivery-date....... 3. Products Product-id, Product-name, supplier-id, category-id..... 4. Suppliers Supplier-id, Company-name, contact-name....... 5. ............................................................ 6. ...

Understanding the while loop in Tensorflow

倖福魔咒の 提交于 2019-12-20 10:08:19
问题 I am using the Python API for Tensorflow. I am trying to implement the Rosenbrock function given below without the use of a Python loop: My current implementation is as follows: def rosenbrock(data_tensor): columns = tf.unstack(data_tensor) summation = 0 for i in range(1, len(columns) - 1): first_term = tf.square(tf.subtract(columns[i + 1], tf.square(columns[i]))) second_term = tf.square(tf.subtract(columns[i], 1.0)) summation += tf.add(tf.multiply(100.0, first_term), second_term) return

Understanding the while loop in Tensorflow

半腔热情 提交于 2019-12-20 10:07:22
问题 I am using the Python API for Tensorflow. I am trying to implement the Rosenbrock function given below without the use of a Python loop: My current implementation is as follows: def rosenbrock(data_tensor): columns = tf.unstack(data_tensor) summation = 0 for i in range(1, len(columns) - 1): first_term = tf.square(tf.subtract(columns[i + 1], tf.square(columns[i]))) second_term = tf.square(tf.subtract(columns[i], 1.0)) summation += tf.add(tf.multiply(100.0, first_term), second_term) return

While loop user input in range

妖精的绣舞 提交于 2019-12-20 07:56:13
问题 I have some code that I want to ask the user for a number between 1-100 and if they put a number between these it will print (Size: (input)) and break the loop, if however, they put in a number outside 1-100 it will print (Size: (input)), and proceed to re-ask them for a number, I have run into some problems though. c=100 while c<100: c=input("Size: ") if c == 1 or 2 or 3: print ("Size: "+c) break else: print ("Size: "+c) print ("Invalid input. Try again.") 回答1: This should do it. c=input(

Why does this do-while loop not produce the right output?

北战南征 提交于 2019-12-20 07:39:42
问题 public static void main(String[] args) throws IOException { System.out.println("Hello, come and play a game with me!"); int x = 5; int guess; do { System.out.println("Please input a number..."); guess = System.in.read(); guess = System.in.read(); if (guess < 5) { System.out.println("You guessed the number!"); break; } } while (guess > 5); } So here I wrote some code. It's supposed to be a guessing game, but no matter what I input, it always gives me in the output "Please input a number..." NO

Compiling c code with bool without using c99 standard

帅比萌擦擦* 提交于 2019-12-20 07:18:05
问题 I've tried to compile a code using a bool variable in C and I've included the stdbool header but when I compiled it I didn't specify that I want to compile it with the c99 standard (so it was compiled with ANSI C standard) but it worked anyway. I was wondering why is that ? Here's the code : #include <stdio.h> #include <stdbool.h> int main() { char name[20]; printf("What's your name ? "); gets(name); printf("Nice to meet you %s.\n", name); bool exit = false; char c; printf("Do you wish to

i can't make num rows inside while looping

独自空忆成欢 提交于 2019-12-20 07:12:47
问题 i have tow tables first table : For products Second Table : For Categories i want to show in browser like this category1 (20) category2 (5) category3 (3) $select_sub_cat = mysql_query("SELECT * FROM sub_cat WHERE ct_id='".$row_main['id']."' "); while($row_sub = mysql_fetch_array($select_sub_cat)) { $select_num_sub = mysql_query("SELECT * FROM market WHERE sub_cat='".$row_sub['id']."' "); $row_num_sub = mysql_num_rows($select_num_sub); $smarty->assign('numb',$row_num_sub); $sub_cats[] = $row