1,为什么background 不起作用
background 简写属性在一个声明中设置所有的背景属性。background出现无法显示通常以下几点:background重复使用,比如background:#fefefe;后面加background:red;优先级问题,(外部样式)External style sheet <(内部样式)Internal style sheet <(内联样式)Inline style写法错误,出现颜色和图片背景时尽量写成一句话比如:body{background:#fefefe url('/templates/red/html/images/main.jpg') no-repeat center top; font-size:14px;}
2,C# WinForm程序中,使用多线程,在关闭窗体时 怎么关闭窗体的所有线程。使程序退出。
程序退出的方法:this.Close(); 只是关闭当前窗口,若不是主窗体的话,是无法退出程序的,另外若有托管线程(非主线程),也无法干净地退出;Application.Exit(); 强制所有消息中止,退出所有的窗体,但是若有托管线程(非主线程),也无法干净地退出;Application.ExitThread(); 强制中止调用线程上的所有消息,同样面临其它线程无法正确退出的问题;System.Environment.Exit(0); 这是最彻底的退出方式,不管什么线程都被强制退出,把程序结束的很干净。
3,C# winform程序 如何用线程实现背景闪烁 我要具体的代码 问题解决会多给分的!
public partial class Form1 : Form
{
Thread t1 = null;
ThreadStart ts = null;
public Form1()
{
InitializeComponent();
init();
}
public void init()
{
ts = new ThreadStart(chCol);
t1 = new Thread(ts);
t1.Start();
}
public void chCol()
{
while (true)
{
Thread.CurrentThread.Join(1000);
if (Form1.ActiveForm.BackColor == Color.Red)
{
Form1.ActiveForm.BackColor = Color.White;
}
else
{
Form1.ActiveForm.BackColor = Color.Red;
}
}
}
}
这是全部的代码,测试过来的。
最后需要重写下窗口关闭事件,在事件中把线程关闭掉,不然会报错.因为人懒,就没写了.
4,用java实现一个可创建4个线程的程序,每个线程在休眠1秒后显示该线程已运行的时间,
测试了一下,应该可以用,你可以试试,不对的地方再问我~public class BaiduThread implements Runnable { private String name; public BaiduThread(String name) { this.name = name; } @Override public void run() { long startTime = System.currentTimeMillis(); long runTime = 0; while(runTime < 10){ try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } runTime = (System.currentTimeMillis() - startTime)/1000; System.out.println(name + " totoal cost : " + runTime + "S"); }}public static void main(String[] args) { for (int i = 1; i <= 4; i++) { BaiduThread baiduThread = new BaiduThread("thread" + i); Thread th = new Thread(baiduThread); th.start(); } }}
5,求解,用c#
控制台程序啊第9题 private static int[] integer = new int[3]; static void Main(string[] args) { for (int i = 0; i < 3; ++i) { Console.WriteLine("请输入第" + (i + 1) + "个整数"); readInt(i); } Console.WriteLine("和为:" + (integer[0] + integer[1] + integer[2])); Console.WriteLine("积为:" + (integer[0] * integer[1] * integer[2])); Console.WriteLine("平均值为:" + ((integer[0] + integer[1] + integer[2]) / 3)); Console.Read(); } static void readInt(int i) { try { integer[i] = Convert.ToInt32(Console.ReadLine()); } catch { Console.WriteLine("输入的不是整数,请重新输入"); readInt(i); } }第10题 static void Main(string[] args) { Console.WriteLine("输入小写字符"); var lowerString = Console.ReadLine(); Console.WriteLine(lowerString.ToUpper()); Console.Read(); }
6,C#中如何调用一个函数?请举例子说明下 谢谢
函数treeFriend_NodeMouseDoubleClick调用了函数friendShow: private void treeFriend_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) { if (treeFriend.SelectedNode.Text != "我的好友") { Thread thread = new Thread(new ParameterizedThreadStart(friendShow)); thread.IsBackground = true; thread.SetApartmentState( ApartmentState.STA); thread.Start(treeFriend.SelectedNode.Text); } }被调用的函数: private void friendShow(object o) { string str = (string)o; Chat mychat = new Chat(); mychat.Text = str; mychat.ShowDialog(); }
7,这是个C# Winform程序,多线程问题。
实现题目的代码如下。解释在代码中:using System;using System.Windows.Forms;using System.Threading;namespace WindowsFormsApplication3{ public partial class Form1 : Form { // 标志:停止线程 bool blnStop; // 委托:用于跨线程调用。计数后台线程和界面主线程是两个不同的 // 的线程。从后台线程调用主线程时要用到这个委托 delegate void ShowCountDelegate(int count); public Form1() { InitializeComponent(); button1.Enabled = true; button2.Enabled = false; } // // “启动计数”按钮 // private void button1_Click(object sender, EventArgs e) { // 启动后台计数线程 blnStop = false; Thread t = new Thread(WorkThread); t.IsBackground = true; t.Start(); button1.Enabled = false; button2.Enabled = true; } // // “停止线程”按钮 // private void button2_Click(object sender, EventArgs e) { blnStop = true; button1.Enabled = true; button2.Enabled = false; } // // 后台计数线程 // private void WorkThread() { int count = 0; while (!blnStop) { count ++; ShowCount(count); // 以下语句让界面刷新 Thread.Sleep(200); } } // // 显示计数值 // private void ShowCount(int count) { if (textBox1.InvokeRequired) { // 需要跨线程处理。利用 BeginInvoke 和前面 // 定义的委托,调用ShowCount(...) textBox1.BeginInvoke( new ShowCountDelegate(ShowCount), count); return; } // 显示计数值 textBox1.Text = count.ToString(); } }}点击“启动计数”点击“停止线程”